#compdef ncspot

autoload -U is-at-least

_ncspot() {
    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[@]}" \
'-d+[Enable debug logging to the specified file]:FILE:_files' \
'--debug=[Enable debug logging to the specified file]:FILE:_files' \
'-b+[custom basepath to config/cache files]:PATH:_files' \
'--basepath=[custom basepath to config/cache files]:PATH:_files' \
'-c+[Filename of config file in basepath]:FILE: ' \
'--config=[Filename of config file in basepath]:FILE: ' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_ncspot_commands" \
"*::: :->ncspot" \
&& ret=0
    case $state in
    (ncspot)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ncspot-command-$line[1]:"
        case $line[1] in
            (info)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ncspot__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_ncspot_commands] )) ||
_ncspot_commands() {
    local commands; commands=(
'info:Print platform information like paths' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ncspot commands' commands "$@"
}
(( $+functions[_ncspot__help_commands] )) ||
_ncspot__help_commands() {
    local commands; commands=(
'info:Print platform information like paths' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ncspot help commands' commands "$@"
}
(( $+functions[_ncspot__help__help_commands] )) ||
_ncspot__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ncspot help help commands' commands "$@"
}
(( $+functions[_ncspot__help__info_commands] )) ||
_ncspot__help__info_commands() {
    local commands; commands=()
    _describe -t commands 'ncspot help info commands' commands "$@"
}
(( $+functions[_ncspot__info_commands] )) ||
_ncspot__info_commands() {
    local commands; commands=()
    _describe -t commands 'ncspot info commands' commands "$@"
}

if [ "$funcstack[1]" = "_ncspot" ]; then
    _ncspot "$@"
else
    compdef _ncspot ncspot
fi
