#compdef dra

autoload -U is-at-least

_dra() {
    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 (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_dra_commands" \
"*::: :->dra" \
&& ret=0
    case $state in
    (dra)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:dra-command-$line[1]:"
        case $line[1] in
            (download)
_arguments "${_arguments_options[@]}" : \
'-s+[Untagged asset name to automatically select which asset to download. This value is usually generated by the command \`untag\`]:SELECT:_default' \
'--select=[Untagged asset name to automatically select which asset to download. This value is usually generated by the command \`untag\`]:SELECT:_default' \
'-t+[Set the tag name for fetching a specific release. Default value is latest release]:TAG:_default' \
'--tag=[Set the tag name for fetching a specific release. Default value is latest release]:TAG:_default' \
'-o+[Save asset to custom path (file or directory). Default path is current working directory and the name of the asset. When used with install feature, it will save the executable to the specified path when applicable. If you install multiple executables, it must be a directory path.]:OUTPUT:_files' \
'--output=[Save asset to custom path (file or directory). Default path is current working directory and the name of the asset. When used with install feature, it will save the executable to the specified path when applicable. If you install multiple executables, it must be a directory path.]:OUTPUT:_files' \
'*-I+[Install downloaded asset and select which executable to install from a tar/zip archive. You can install multiple executables by specifying \`-I/--install-file\` multiple times.]:INSTALL_FILE:_default' \
'*--install-file=[Install downloaded asset and select which executable to install from a tar/zip archive. You can install multiple executables by specifying \`-I/--install-file\` multiple times.]:INSTALL_FILE:_default' \
'-a[Automatically select and download an asset based on your operating system and architecture]' \
'--automatic[Automatically select and download an asset based on your operating system and architecture]' \
'-i[Install downloaded asset]' \
'--install[Install downloaded asset]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':repo -- GitHub repository using format {owner}/{repo}:_default' \
&& ret=0
;;
(untag)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':repo -- GitHub repository using format {owner}/{repo}:_default' \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell -- Shell to generate completion for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_dra__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:dra-help-command-$line[1]:"
        case $line[1] in
            (download)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(untag)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_dra_commands] )) ||
_dra_commands() {
    local commands; commands=(
'download:Select and download an asset' \
'untag:Select an asset and generate an untagged version of it' \
'completion:Generate shell completion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'dra commands' commands "$@"
}
(( $+functions[_dra__completion_commands] )) ||
_dra__completion_commands() {
    local commands; commands=()
    _describe -t commands 'dra completion commands' commands "$@"
}
(( $+functions[_dra__download_commands] )) ||
_dra__download_commands() {
    local commands; commands=()
    _describe -t commands 'dra download commands' commands "$@"
}
(( $+functions[_dra__help_commands] )) ||
_dra__help_commands() {
    local commands; commands=(
'download:Select and download an asset' \
'untag:Select an asset and generate an untagged version of it' \
'completion:Generate shell completion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'dra help commands' commands "$@"
}
(( $+functions[_dra__help__completion_commands] )) ||
_dra__help__completion_commands() {
    local commands; commands=()
    _describe -t commands 'dra help completion commands' commands "$@"
}
(( $+functions[_dra__help__download_commands] )) ||
_dra__help__download_commands() {
    local commands; commands=()
    _describe -t commands 'dra help download commands' commands "$@"
}
(( $+functions[_dra__help__help_commands] )) ||
_dra__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'dra help help commands' commands "$@"
}
(( $+functions[_dra__help__untag_commands] )) ||
_dra__help__untag_commands() {
    local commands; commands=()
    _describe -t commands 'dra help untag commands' commands "$@"
}
(( $+functions[_dra__untag_commands] )) ||
_dra__untag_commands() {
    local commands; commands=()
    _describe -t commands 'dra untag commands' commands "$@"
}

if [ "$funcstack[1]" = "_dra" ]; then
    _dra "$@"
else
    compdef _dra dra
fi
