#compdef clyde

autoload -U is-at-least

_clyde() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_clyde_commands" \
"*::: :->clyde" \
&& ret=0
    case $state in
    (clyde)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:clyde-command-$line[1]:"
        case $line[1] in
            (setup)
_arguments "${_arguments_options[@]}" : \
'--url=[URL of the Git repository to use for the store]:STORE_URL:_default' \
'-u[Update the activation scripts of an existing installation]' \
'--update-scripts[Update the activation scripts of an existing installation]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(install)
_arguments "${_arguments_options[@]}" : \
'-r[Uninstall then reinstall already installed packages]' \
'--reinstall[Uninstall then reinstall already installed packages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::package_names -- Application name, optionally suffixed with @version:_default' \
&& ret=0
;;
(uninstall)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'*::package_names -- Application name:_default' \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
'-f[Show package files instead of package details]' \
'--files[Show package files instead of package details]' \
'-r[Show package releases instead of package details]' \
'--releases[Show package releases instead of package details]' \
'-j[JSON output]' \
'--json[JSON output]' \
'-h[Print help]' \
'--help[Print help]' \
':package_name -- Package name:_default' \
&& ret=0
;;
(search)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':query -- Search query:_default' \
&& ret=0
;;
(doc)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':package_name -- Application name:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'-j[Use JSON output]' \
'--json[Use JSON output]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(upgrade)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_clyde__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:clyde-help-command-$line[1]:"
        case $line[1] in
            (setup)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(uninstall)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(search)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(doc)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(upgrade)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_clyde_commands] )) ||
_clyde_commands() {
    local commands; commands=(
'setup:Setup Clyde' \
'update:Update Clyde store' \
'install:Install applications' \
'uninstall:Uninstall applications (alias\: remove)' \
'show:Show details about a package' \
'search:Search for available applications' \
'doc:Read documentation files provided by an application' \
'list:List installed applications' \
'upgrade:Upgrade all installed applications, enforcing pinning' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'clyde commands' commands "$@"
}
(( $+functions[_clyde__subcmd__doc_commands] )) ||
_clyde__subcmd__doc_commands() {
    local commands; commands=()
    _describe -t commands 'clyde doc commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help_commands] )) ||
_clyde__subcmd__help_commands() {
    local commands; commands=(
'setup:Setup Clyde' \
'update:Update Clyde store' \
'install:Install applications' \
'uninstall:Uninstall applications (alias\: remove)' \
'show:Show details about a package' \
'search:Search for available applications' \
'doc:Read documentation files provided by an application' \
'list:List installed applications' \
'upgrade:Upgrade all installed applications, enforcing pinning' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'clyde help commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__doc_commands] )) ||
_clyde__subcmd__help__subcmd__doc_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help doc commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__help_commands] )) ||
_clyde__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help help commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__install_commands] )) ||
_clyde__subcmd__help__subcmd__install_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help install commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__list_commands] )) ||
_clyde__subcmd__help__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help list commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__search_commands] )) ||
_clyde__subcmd__help__subcmd__search_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help search commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__setup_commands] )) ||
_clyde__subcmd__help__subcmd__setup_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help setup commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__show_commands] )) ||
_clyde__subcmd__help__subcmd__show_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help show commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__uninstall_commands] )) ||
_clyde__subcmd__help__subcmd__uninstall_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help uninstall commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__update_commands] )) ||
_clyde__subcmd__help__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help update commands' commands "$@"
}
(( $+functions[_clyde__subcmd__help__subcmd__upgrade_commands] )) ||
_clyde__subcmd__help__subcmd__upgrade_commands() {
    local commands; commands=()
    _describe -t commands 'clyde help upgrade commands' commands "$@"
}
(( $+functions[_clyde__subcmd__install_commands] )) ||
_clyde__subcmd__install_commands() {
    local commands; commands=()
    _describe -t commands 'clyde install commands' commands "$@"
}
(( $+functions[_clyde__subcmd__list_commands] )) ||
_clyde__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'clyde list commands' commands "$@"
}
(( $+functions[_clyde__subcmd__search_commands] )) ||
_clyde__subcmd__search_commands() {
    local commands; commands=()
    _describe -t commands 'clyde search commands' commands "$@"
}
(( $+functions[_clyde__subcmd__setup_commands] )) ||
_clyde__subcmd__setup_commands() {
    local commands; commands=()
    _describe -t commands 'clyde setup commands' commands "$@"
}
(( $+functions[_clyde__subcmd__show_commands] )) ||
_clyde__subcmd__show_commands() {
    local commands; commands=()
    _describe -t commands 'clyde show commands' commands "$@"
}
(( $+functions[_clyde__subcmd__uninstall_commands] )) ||
_clyde__subcmd__uninstall_commands() {
    local commands; commands=()
    _describe -t commands 'clyde uninstall commands' commands "$@"
}
(( $+functions[_clyde__subcmd__update_commands] )) ||
_clyde__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'clyde update commands' commands "$@"
}
(( $+functions[_clyde__subcmd__upgrade_commands] )) ||
_clyde__subcmd__upgrade_commands() {
    local commands; commands=()
    _describe -t commands 'clyde upgrade commands' commands "$@"
}

if [ "$funcstack[1]" = "_clyde" ]; then
    _clyde "$@"
else
    compdef _clyde clyde
fi
