#compdef voa

autoload -U is-at-least

_voa() {
    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[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_voa_commands" \
"*::: :->voa" \
&& ret=0
    case $state in
    (voa)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:voa-command-$line[1]:"
        case $line[1] in
            (import)
_arguments "${_arguments_options[@]}" : \
'-c+[The context to import for.]:CONTEXT:_default' \
'--context=[The context to import for.]:CONTEXT:_default' \
'-i+[The directory or file to import from.]:INPUT:_default' \
'--input=[The directory or file to import from.]:INPUT:_default' \
'-b+[The VOA base path to write to.]:BASE_PATH:_files' \
'--base-path=[The VOA base path to write to.]:BASE_PATH:_files' \
'(-b --base-path)-r[Whether to import to the runtime directory.]' \
'(-b --base-path)--runtime[Whether to import to the runtime directory.]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':os -- The OS to import for.:_default' \
':purpose -- The purpose to import for.:_default' \
':technology -- The technology to import for.:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'--context=[The context to search for.]:CONTEXT:_default' \
'-t+[The technology to search for.]:TECHNOLOGY:_default' \
'--technology=[The technology to search for.]:TECHNOLOGY:_default' \
'-o+[The output format to use.]:OUTPUT_FORMAT:((json\:"The JSON output format"
text\:"The default text output format"))' \
'--output-format=[The output format to use.]:OUTPUT_FORMAT:((json\:"The JSON output format"
text\:"The default text output format"))' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':os -- The OS to search for.:_default' \
':purpose -- The purpose to search for.:_default' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" : \
'-o+[The output format to use.]:OUTPUT_FORMAT:((json\:"The JSON output format"
text\:"The default text output format"))' \
'--output-format=[The output format to use.]:OUTPUT_FORMAT:((json\:"The JSON output format"
text\:"The default text output format"))' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':os -- The OS to verify for.:_default' \
':purpose -- The purpose to verify for.:_default' \
':context -- The context to verify for.:_default' \
':technology -- The technology to verify with.:_default' \
':file -- The file to verify.:_default' \
'*::signatures -- The signature to verify a file with.:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_voa__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_voa_commands] )) ||
_voa_commands() {
    local commands; commands=(
'import:Import a single verifier into a VOA hierarchy.' \
'list:List all verifiers in VOA that match provided identifiers.' \
'verify:Verify a file using suitable verifiers and signatures.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'voa commands' commands "$@"
}
(( $+functions[_voa__help_commands] )) ||
_voa__help_commands() {
    local commands; commands=(
'import:Import a single verifier into a VOA hierarchy.' \
'list:List all verifiers in VOA that match provided identifiers.' \
'verify:Verify a file using suitable verifiers and signatures.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'voa help commands' commands "$@"
}
(( $+functions[_voa__help__help_commands] )) ||
_voa__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'voa help help commands' commands "$@"
}
(( $+functions[_voa__help__import_commands] )) ||
_voa__help__import_commands() {
    local commands; commands=()
    _describe -t commands 'voa help import commands' commands "$@"
}
(( $+functions[_voa__help__list_commands] )) ||
_voa__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'voa help list commands' commands "$@"
}
(( $+functions[_voa__help__verify_commands] )) ||
_voa__help__verify_commands() {
    local commands; commands=()
    _describe -t commands 'voa help verify commands' commands "$@"
}
(( $+functions[_voa__import_commands] )) ||
_voa__import_commands() {
    local commands; commands=()
    _describe -t commands 'voa import commands' commands "$@"
}
(( $+functions[_voa__list_commands] )) ||
_voa__list_commands() {
    local commands; commands=()
    _describe -t commands 'voa list commands' commands "$@"
}
(( $+functions[_voa__verify_commands] )) ||
_voa__verify_commands() {
    local commands; commands=()
    _describe -t commands 'voa verify commands' commands "$@"
}

if [ "$funcstack[1]" = "_voa" ]; then
    _voa "$@"
else
    compdef _voa voa
fi
