#compdef kingler

autoload -U is-at-least

_kingler() {
    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]' \
":: :_kingler_commands" \
"*::: :->kingler" \
&& ret=0
    case $state in
    (kingler)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kingler-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'::bash:' \
'::zsh:' \
'::fish:' \
'::powershell:' \
'::elvish:' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(name)
_arguments "${_arguments_options[@]}" : \
'-i[Print pokedex entry (if it exists)]' \
'--info[Print pokedex entry (if it exists)]' \
'-s[Show the shiny pokemon version instead]' \
'--shiny[Show the shiny pokemon version instead]' \
'--game-info[Choose a game for the pokedex entry]' \
'--no-title[Do not display pokemon name]' \
'--padding-left[Set amount of padding to the left \[default\: 0\]]' \
'-u[Show the pokedex entry under the pokemon]' \
'--under[Show the pokedex entry under the pokemon]' \
'--stats[Show the pokemon stats]' \
'-h[Print help]' \
'--help[Print help]' \
'::name -- Who'\''s that pokemon!?:' \
&& ret=0
;;
(random)
_arguments "${_arguments_options[@]}" : \
'-i[Print pokedex entry (if it exists)]' \
'--info[Print pokedex entry (if it exists)]' \
'-s[Show the shiny pokemon version instead]' \
'--shiny[Show the shiny pokemon version instead]' \
'--game-info[Choose a game for the pokedex entry]' \
'--no-title[Do not display pokemon name]' \
'--padding-left[Set amount of padding to the left \[default\: 0\]]' \
'-u[Show the pokedex entry under the pokemon]' \
'--under[Show the pokedex entry under the pokemon]' \
'--stats[Show the pokemon stats]' \
'--no-mega[Do not show mega pokemon]' \
'--no-gmax[Do not show gigantamax pokemon]' \
'--no-regional[Do not show regional pokemon]' \
'-h[Print help]' \
'--help[Print help]' \
'::GENERATIONS -- Generation number, range (1-9), or list of generations (1,3,6) \[default\: 1-9\]:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_kingler__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kingler-help-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(name)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(random)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_kingler_commands] )) ||
_kingler_commands() {
    local commands; commands=(
'init:Generate shell completions' \
'list:List all names of pokemons' \
'name:Select pokemon by name\: eg. '\''pikachu'\''' \
'random:Show random pokemon' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kingler commands' commands "$@"
}
(( $+functions[_kingler__help_commands] )) ||
_kingler__help_commands() {
    local commands; commands=(
'init:Generate shell completions' \
'list:List all names of pokemons' \
'name:Select pokemon by name\: eg. '\''pikachu'\''' \
'random:Show random pokemon' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kingler help commands' commands "$@"
}
(( $+functions[_kingler__help__help_commands] )) ||
_kingler__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'kingler help help commands' commands "$@"
}
(( $+functions[_kingler__help__init_commands] )) ||
_kingler__help__init_commands() {
    local commands; commands=()
    _describe -t commands 'kingler help init commands' commands "$@"
}
(( $+functions[_kingler__help__list_commands] )) ||
_kingler__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'kingler help list commands' commands "$@"
}
(( $+functions[_kingler__help__name_commands] )) ||
_kingler__help__name_commands() {
    local commands; commands=()
    _describe -t commands 'kingler help name commands' commands "$@"
}
(( $+functions[_kingler__help__random_commands] )) ||
_kingler__help__random_commands() {
    local commands; commands=()
    _describe -t commands 'kingler help random commands' commands "$@"
}
(( $+functions[_kingler__init_commands] )) ||
_kingler__init_commands() {
    local commands; commands=()
    _describe -t commands 'kingler init commands' commands "$@"
}
(( $+functions[_kingler__list_commands] )) ||
_kingler__list_commands() {
    local commands; commands=()
    _describe -t commands 'kingler list commands' commands "$@"
}
(( $+functions[_kingler__name_commands] )) ||
_kingler__name_commands() {
    local commands; commands=()
    _describe -t commands 'kingler name commands' commands "$@"
}
(( $+functions[_kingler__random_commands] )) ||
_kingler__random_commands() {
    local commands; commands=()
    _describe -t commands 'kingler random commands' commands "$@"
}

if [ "$funcstack[1]" = "_kingler" ]; then
    _kingler "$@"
else
    compdef _kingler kingler
fi
