#compdef sqv

autoload -U is-at-least

_sqv() {
    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[@]}" : \
'(--signature-file)--output=[Write to FILE or stdout if omitted]:FILE:_files' \
'--signature-file=[Verify a detached signature file]:SIG:_files' \
'*--keyring=[A keyring]:FILE:_files' \
'--not-after=[Consider signatures created after TIMESTAMP as invalid]:TIMESTAMP:_default' \
'--not-before=[Consider signatures created before TIMESTAMP as invalid]:TIMESTAMP:_default' \
'-n+[The number of valid signatures to return success]:N:_default' \
'--signatures=[The number of valid signatures to return success]:N:_default' \
'--policy-as-of=[Select the cryptographic policy as of the specified time]:TIMESTAMP:_default' \
'--message[Verify an inline signed message]' \
'--cleartext[Verify a cleartext-signed message]' \
'-v[Be verbose]' \
'--verbose[Be verbose]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
':file -- The inline-signed message, message using the Cleartext Signature Framework, or data file:_files' \
'::data -- In the legacy way of invoking sqv, the signature file is given as first positional argument, and the data file as second:_files' \
&& ret=0
}

(( $+functions[_sqv_commands] )) ||
_sqv_commands() {
    local commands; commands=()
    _describe -t commands 'sqv commands' commands "$@"
}

if [ "$funcstack[1]" = "_sqv" ]; then
    _sqv "$@"
else
    compdef _sqv sqv
fi