#compdef pvinfo

autoload -U is-at-least

_pvinfo() {
    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[@]}" : \
'--format=[Select the output format]:FORMAT:((human\:"Human-readable format"
yaml\:"YAML format"))' \
'--se-status[Display the Secure Execution status of the system]' \
'--facilities[Show installed Ultravisor calls]' \
'--feature-indications[Show Ultravisor feature indications]' \
'--supported-plaintext-attestation-flags[Show supported plaintext attestation flags]' \
'--supported-se-header-versions[Show supported SE header versions]' \
'--supported-secret-types[Show supported secret types]' \
'--supported-plaintext-control-flags[Show supported plaintext control flags]' \
'--supported-attestation-request-versions[Show supported attestation request versions]' \
'--supported-add-secret-request-versions[Show supported add-secret request versions]' \
'--supported-plaintext-add-secret-flags[Show supported plaintext add-secret flags]' \
'--limits[Show Secure Execution limits]' \
'--version[Print version information and exit]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
":: :_pvinfo_commands" \
"*::: :->pvinfo" \
&& ret=0
    case $state in
    (pvinfo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:pvinfo-command-$line[1]:"
        case $line[1] in
            (supported-flags)
_arguments "${_arguments_options[@]}" : \
'--secret[Show supported secret-related flags]' \
'--attestation[Show supported attestation-related flags]' \
'--header[Show supported header-related flags]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_pvinfo__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_pvinfo_commands] )) ||
_pvinfo_commands() {
    local commands; commands=(
'supported-flags:Query supported flags grouped by category' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvinfo commands' commands "$@"
}
(( $+functions[_pvinfo__help_commands] )) ||
_pvinfo__help_commands() {
    local commands; commands=(
'supported-flags:Query supported flags grouped by category' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvinfo help commands' commands "$@"
}
(( $+functions[_pvinfo__help__help_commands] )) ||
_pvinfo__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'pvinfo help help commands' commands "$@"
}
(( $+functions[_pvinfo__help__supported-flags_commands] )) ||
_pvinfo__help__supported-flags_commands() {
    local commands; commands=()
    _describe -t commands 'pvinfo help supported-flags commands' commands "$@"
}
(( $+functions[_pvinfo__supported-flags_commands] )) ||
_pvinfo__supported-flags_commands() {
    local commands; commands=()
    _describe -t commands 'pvinfo supported-flags commands' commands "$@"
}

if [ "$funcstack[1]" = "_pvinfo" ]; then
    _pvinfo "$@"
else
    compdef _pvinfo pvinfo
fi
