#compdef pvimg

autoload -U is-at-least

_pvimg() {
    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'\'')]' \
":: :_pvimg_commands" \
"*::: :->pvimg" \
&& ret=0
    case $state in
    (pvimg)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:pvimg-command-$line[1]:"
        case $line[1] in
            (create)
_arguments "${_arguments_options[@]}" : \
'-i+[Use the content of FILE as a raw binary Linux kernel]:FILE:_files' \
'--kernel=[Use the content of FILE as a raw binary Linux kernel]:FILE:_files' \
'--image=[Use the content of FILE as a raw binary Linux kernel]:FILE:_files' \
'-r+[Use the content of FILE as the Linux initial RAM disk]:FILE:_files' \
'--ramdisk=[Use the content of FILE as the Linux initial RAM disk]:FILE:_files' \
'-p+[Use the content of FILE as the Linux kernel command line]:FILE:_files' \
'--parmfile=[Use the content of FILE as the Linux kernel command line]:FILE:_files' \
'-o+[Write the generated Secure Execution boot image to FILE]:FILE:_files' \
'--output=[Write the generated Secure Execution boot image to FILE]:FILE:_files' \
'*-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' \
'--cck=[Use the content of FILE as the customer-communication key (CCK)]:FILE:_files' \
'--comm-key=[Use the content of FILE as the customer-communication key (CCK)]:FILE:_files' \
'--hdr-key=[Use the content of FILE as the Secure Execution header protection key]:FILE:_files' \
'--x-bootloader-directory=[Manually set the directory used to load the Secure Execution bootloaders (stage3a and stage3b) (experimental option)]:DIR:_files' \
'--x-comp-key=[Manually set the image components encryption key (experimental option)]:FILE:_files' \
'--x-psw=[Manually set the PSW address used for the Secure Execution header (experimental option)]:ADDRESS:_default' \
'--x-pcf=[Manually set the plaintext control flags (experimental option)]:PCF:_default' \
'--x-scf=[Manually set the secret control flags (experimental option)]:SCF:_default' \
'--no-verify[Disable the host-key document verification]' \
'--offline[Make no attempt to download CRLs]' \
'--no-component-check[Disable all input component checks]' \
'--overwrite[Overwrite an existing Secure Execution boot image]' \
'--enable-dump[Enable Secure Execution guest dump support. This option requires the '\''--cck'\'' or '\''--enable-cck-update'\'' option]' \
'(--enable-dump)--disable-dump[Disable Secure Execution guest dump support (default)]' \
'--enable-cck-extension-secret[Add-secret requests must provide an extension secret that matches the CCK-derived extension secret. This option requires the '\''--cck'\'' option]' \
'(--enable-cck-extension-secret)--disable-cck-extension-secret[Add-secret requests don'\''t have to provide the CCK-derived extension secret (default)]' \
'(--enable-cck-extension-secret)--enable-cck-update[Enable CCK update support. Requires z17 or up. This option cannot be used in conjunction with the '\''--enable-cck-extension-secret'\'' option]' \
'(--enable-cck-update)--disable-cck-update[Disable CCK update support (default)]' \
'--enable-pckmo[Enable the support for the DEA, TDEA, AES, and ECC PCKMO key encryption functions (default)]' \
'(--enable-pckmo)--disable-pckmo[Disable the support for the DEA, TDEA, AES, and ECC PCKMO key encryption functions]' \
'--enable-pckmo-hmac[Enable the support for the HMAC PCKMO key encryption function]' \
'(--enable-pckmo-hmac)--disable-pckmo-hmac[Disable the support for the HMAC PCKMO key encryption function (default)]' \
'--enable-backup-keys[Enable the support for backup target keys]' \
'(--enable-backup-keys)--disable-backup-keys[Disable the support for backup target keys (default)]' \
'--enable-image-encryption[Enable encryption of the image components (default)]' \
'(--enable-image-encryption)--disable-image-encryption[Disable encryption of the image components]' \
'*-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
;;
(info)
_arguments "${_arguments_options[@]}" : \
'--format=[The output format]:FORMAT:((json\:"JSON format"))' \
'--hdr-key=[Use the key in FILE to decrypt the Secure Execution header]: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'\'')]' \
':path -- Use INPUT as the Secure Execution image:_files' \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
'*-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' \
'(-k --host-key-document)--key-hashes=[Use FILE to check for the host key hashes provided by the ultravisor. If no FILE is specified, FILE defaults to '\''/sys/firmware/uv/keys/all'\'']' \
'*-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'\'')]' \
':path -- Use INPUT as the Secure Execution image:_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[@]}" : \
":: :_pvimg__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_pvimg_commands] )) ||
_pvimg_commands() {
    local commands; commands=(
'create:Create an IBM Secure Execution image' \
'info:Print information about the IBM Secure Execution image' \
'test:Test different aspects of an existing IBM Secure Execution image' \
'version:Print version information and exit' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvimg commands' commands "$@"
}
(( $+functions[_pvimg__create_commands] )) ||
_pvimg__create_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg create commands' commands "$@"
}
(( $+functions[_pvimg__help_commands] )) ||
_pvimg__help_commands() {
    local commands; commands=(
'create:Create an IBM Secure Execution image' \
'info:Print information about the IBM Secure Execution image' \
'test:Test different aspects of an existing IBM Secure Execution image' \
'version:Print version information and exit' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'pvimg help commands' commands "$@"
}
(( $+functions[_pvimg__help__create_commands] )) ||
_pvimg__help__create_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg help create commands' commands "$@"
}
(( $+functions[_pvimg__help__help_commands] )) ||
_pvimg__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg help help commands' commands "$@"
}
(( $+functions[_pvimg__help__info_commands] )) ||
_pvimg__help__info_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg help info commands' commands "$@"
}
(( $+functions[_pvimg__help__test_commands] )) ||
_pvimg__help__test_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg help test commands' commands "$@"
}
(( $+functions[_pvimg__help__version_commands] )) ||
_pvimg__help__version_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg help version commands' commands "$@"
}
(( $+functions[_pvimg__info_commands] )) ||
_pvimg__info_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg info commands' commands "$@"
}
(( $+functions[_pvimg__test_commands] )) ||
_pvimg__test_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg test commands' commands "$@"
}
(( $+functions[_pvimg__version_commands] )) ||
_pvimg__version_commands() {
    local commands; commands=()
    _describe -t commands 'pvimg version commands' commands "$@"
}

if [ "$funcstack[1]" = "_pvimg" ]; then
    _pvimg "$@"
else
    compdef _pvimg pvimg
fi
