#compdef oparlint

autoload -U is-at-least

_oparlint() {
    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]' \
":: :_oparlint_commands" \
"*::: :->oparlint" \
&& ret=0
    case $state in
    (oparlint)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:oparlint-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':url -- The URL endpoint where the OParl system is expected:_default' \
&& ret=0
;;
(generate-shell-completion)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_oparlint__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_oparlint_commands] )) ||
_oparlint_commands() {
    local commands; commands=(
'check:Check a URL endpoint for compliance with OParl' \
'generate-shell-completion:Generate shell comletion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'oparlint commands' commands "$@"
}
(( $+functions[_oparlint__check_commands] )) ||
_oparlint__check_commands() {
    local commands; commands=()
    _describe -t commands 'oparlint check commands' commands "$@"
}
(( $+functions[_oparlint__generate-shell-completion_commands] )) ||
_oparlint__generate-shell-completion_commands() {
    local commands; commands=()
    _describe -t commands 'oparlint generate-shell-completion commands' commands "$@"
}
(( $+functions[_oparlint__help_commands] )) ||
_oparlint__help_commands() {
    local commands; commands=(
'check:Check a URL endpoint for compliance with OParl' \
'generate-shell-completion:Generate shell comletion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'oparlint help commands' commands "$@"
}
(( $+functions[_oparlint__help__check_commands] )) ||
_oparlint__help__check_commands() {
    local commands; commands=()
    _describe -t commands 'oparlint help check commands' commands "$@"
}
(( $+functions[_oparlint__help__generate-shell-completion_commands] )) ||
_oparlint__help__generate-shell-completion_commands() {
    local commands; commands=()
    _describe -t commands 'oparlint help generate-shell-completion commands' commands "$@"
}
(( $+functions[_oparlint__help__help_commands] )) ||
_oparlint__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'oparlint help help commands' commands "$@"
}

if [ "$funcstack[1]" = "_oparlint" ]; then
    _oparlint "$@"
else
    compdef _oparlint oparlint
fi
