#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]:SELECT: ' \
'--select=[Untagged asset name to automatically select which asset to download]:SELECT: ' \
'-t+[Set the tag name for fetching a specific release]:TAG: ' \
'--tag=[Set the tag name for fetching a specific release]:TAG: ' \
'-o+[Save asset to custom path (file or directory)]:OUTPUT:_files' \
'--output=[Save asset to custom path (file or directory)]:OUTPUT:_files' \
'-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}:' \
&& ret=0
;;
(untag)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
':repo -- Github repository using format {owner}/{repo}:' \
&& 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__help__completion_commands] )) ||
_dra__help__completion_commands() {
    local commands; commands=()
    _describe -t commands 'dra help completion commands' commands "$@"
}
(( $+functions[_dra__download_commands] )) ||
_dra__download_commands() {
    local commands; commands=()
    _describe -t commands 'dra download 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_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__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
