#compdef pvattest

autoload -U is-at-least

_pvattest() {
    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[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'--version[Print version information and exit]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
":: :_pvattest_commands" \
"*::: :->pvattest" \
&& ret=0
    case $state in
    (pvattest)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:pvattest-command-$line[1]:"
        case $line[1] in
            (create)
_arguments "${_arguments_options[@]}" : \
'*-k+[Use FILE as a host-key document]:FILE:_files' \
'*--host-key-document=[Use FILE as a host-key document]:FILE:_files' \
'*-C+[Use FILE as a certificate to verify the host-key or keys]:FILE:_files' \
'*--cert=[Use FILE as a certificate to verify the host-key or keys]:FILE:_files' \
'*--crl=[Use FILE as a certificate revocation list (CRL)]:FILE:_files' \
'--root-ca=[Use FILE as the root-CA certificate for the verification]:ROOT_CA:_files' \
'-o+[Write the generated request to FILE]:FILE:_files' \
'--output=[Write the generated request to FILE]:FILE:_files' \
'-a+[Save the protection key as unencrypted GCM-AES256 key in FILE]:FILE:_files' \
'--arpk=[Save the protection key as unencrypted GCM-AES256 key in FILE]:FILE:_files' \
'*--add-data=[Specify additional data for the request]:FLAGS:((phkh-img\:"Request the public host-key-hash of the key that decrypted the SE-image as additional-data"
phkh-att\:"Request the public host-key-hash of the key that decrypted the attestation request as additional-data"
secret-store-hash\:"Request a hash over all successful Add-secret requests and the lock state as additional-data"
firmware-state\:"Request the state of the firmware as additional-data"))' \
'--no-verify[Disable the host-key document verification]' \
'--offline[Make no attempt to download CRLs]' \
'*-v[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(perform)
_arguments "${_arguments_options[@]}" : \
'-i+[Specify the request to be sent]:FILE:_files' \
'--input=[Specify the request to be sent]:FILE:_files' \
'-o+[Write the result to FILE]:FILE:_files' \
'--output=[Write the result to FILE]:FILE:_files' \
'-u+[Provide up to 256 bytes of user input]:File:_files' \
'--user-data=[Provide up to 256 bytes of user input]:File:_files' \
'*-v[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::input_pos -- Specify the request to be sent:_files' \
'::output_pos -- Write the result to FILE:_files' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" : \
'-i+[Specify the attestation response to be verified]:FILE:_files' \
'--input=[Specify the attestation response to be verified]:FILE:_files' \
'-o+[Specify the output for the verification result]:FILE:_files' \
'--output=[Specify the output for the verification result]:FILE:_files' \
'--hdr=[Specifies the header of the guest image]:FILE:_files' \
'-a+[Use FILE as the protection key to decrypt the request]:FILE:_files' \
'--arpk=[Use FILE as the protection key to decrypt the request]:FILE:_files' \
'--format=[Define the output format]:FORMAT:((yaml\:"Use yaml format"))' \
'-u+[Write the user data to the FILE if any]:FILE:_files' \
'--user-data=[Write the user data to the FILE if any]:FILE:_files' \
'*-v[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
'--format=[Define the output format]:FORMAT:((yaml\:"Use yaml format"))' \
'*-k+[Use FILE to check for a  host-key document]:FILE:_files' \
'*--host-key-document=[Use FILE to check for a  host-key document]:FILE:_files' \
'*--host-key-check=[Define the host-key check policy]:HOST_KEY_CHECKS:((att-key-hash\:"Check the host-key used for the attestation request"
boot-key-hash\:"Check the host-key used to the boot the image"))' \
'-u+[Check if the provided user data matches the data from the attestation response]:FILE:_files' \
'--user-data=[Check if the provided user data matches the data from the attestation response]:FILE:_files' \
'*--secret=[Use FILE to include as successful Add-secret request]:FILE:_files' \
'--secret-store-locked=[Check whether the guests secret store is locked or not]:BOOL:(true false)' \
'--firmware-verify-url=[Specify the endpoint to use for firmware version verification]:URL:_urls' \
'--firmware[Check whether the firmware is supported by IBM]' \
'*-v[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':input -- Specify the attestation response to check whether the policies are validated:_files' \
':output -- Specify the output file for the check result:_files' \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" : \
'*-v[Provide more detailed output]' \
'*--verbose[Provide more detailed output]' \
'(-v --verbose)*-q[Provide less output]' \
'(-v --verbose)*--quiet[Provide less output]' \
'*-V[Provide more detailed output]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_pvattest__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_pvattest_commands] )) ||
_pvattest_commands() {
    local commands; commands=(
'create:Create an attestation measurement request' \
'perform:Send the attestation request to the Ultravisor' \
'verify:Verify an attestation response' \
'check:Check if the attestation result matches defined policies' \
'version:Print version information and exit' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvattest commands' commands "$@"
}
(( $+functions[_pvattest__check_commands] )) ||
_pvattest__check_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest check commands' commands "$@"
}
(( $+functions[_pvattest__create_commands] )) ||
_pvattest__create_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest create commands' commands "$@"
}
(( $+functions[_pvattest__help_commands] )) ||
_pvattest__help_commands() {
    local commands; commands=(
'create:Create an attestation measurement request' \
'perform:Send the attestation request to the Ultravisor' \
'verify:Verify an attestation response' \
'check:Check if the attestation result matches defined policies' \
'version:Print version information and exit' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvattest help commands' commands "$@"
}
(( $+functions[_pvattest__help__check_commands] )) ||
_pvattest__help__check_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help check commands' commands "$@"
}
(( $+functions[_pvattest__help__create_commands] )) ||
_pvattest__help__create_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help create commands' commands "$@"
}
(( $+functions[_pvattest__help__help_commands] )) ||
_pvattest__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help help commands' commands "$@"
}
(( $+functions[_pvattest__help__perform_commands] )) ||
_pvattest__help__perform_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help perform commands' commands "$@"
}
(( $+functions[_pvattest__help__verify_commands] )) ||
_pvattest__help__verify_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help verify commands' commands "$@"
}
(( $+functions[_pvattest__help__version_commands] )) ||
_pvattest__help__version_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest help version commands' commands "$@"
}
(( $+functions[_pvattest__perform_commands] )) ||
_pvattest__perform_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest perform commands' commands "$@"
}
(( $+functions[_pvattest__verify_commands] )) ||
_pvattest__verify_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest verify commands' commands "$@"
}
(( $+functions[_pvattest__version_commands] )) ||
_pvattest__version_commands() {
    local commands; commands=()
    _describe -t commands 'pvattest version commands' commands "$@"
}

if [ "$funcstack[1]" = "_pvattest" ]; then
    _pvattest "$@"
else
    compdef _pvattest pvattest
fi
