#compdef cksum

autoload -U is-at-least

_cksum() {
    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[@]}" : \
'-a+[cksum-help-algorithm]:ALGORITHM:(sysv bsd crc crc32b md5 sha1 sha3 sha224 sha256 sha384 sha512 blake2b blake3 sm3 shake128 shake256)' \
'--algorithm=[cksum-help-algorithm]:ALGORITHM:(sysv bsd crc crc32b md5 sha1 sha3 sha224 sha256 sha384 sha512 blake2b blake3 sm3 shake128 shake256)' \
'-l+[cksum-help-length]: :_default' \
'--length=[cksum-help-length]: :_default' \
'--untagged[cksum-help-untagged]' \
'--tag[cksum-help-tag]' \
'--raw[cksum-help-raw]' \
'--strict[cksum-help-strict]' \
'-c[cksum-help-check]' \
'--check[cksum-help-check]' \
'(--raw)--base64[cksum-help-base64]' \
'-t[]' \
'--text[]' \
'-b[]' \
'--binary[]' \
'-w[cksum-help-warn]' \
'--warn[cksum-help-warn]' \
'--status[cksum-help-status]' \
'--quiet[cksum-help-quiet]' \
'--ignore-missing[cksum-help-ignore-missing]' \
'-z[cksum-help-zero]' \
'--zero[cksum-help-zero]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_cksum" ]; then
    _cksum "$@"
else
    compdef _cksum cksum
fi
