#compdef b2sum

autoload -U is-at-least

_b2sum() {
    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[@]}" : \
'-l+[digest length in bits; must not exceed the max size and must be a multiple of 8 for blake2b; must be 224, 256, 384, or 512 for sha2 or sha3]: :_default' \
'--length=[digest length in bits; must not exceed the max size and must be a multiple of 8 for blake2b; must be 224, 256, 384, or 512 for sha2 or sha3]: :_default' \
'-b[]' \
'--binary[]' \
'-c[read checksums from the FILEs and check them]' \
'--check[read checksums from the FILEs and check them]' \
'-w[warn about improperly formatted checksum lines]' \
'--warn[warn about improperly formatted checksum lines]' \
'--status[don'\''t output anything, status code shows success]' \
'--quiet[don'\''t print OK for each successfully verified file]' \
'--ignore-missing[don'\''t fail or report status for missing files]' \
'--strict[exit non-zero for improperly formatted checksum lines]' \
'--tag[create a BSD style checksum]' \
'-t[read in text mode (default)]' \
'--text[read in text mode (default)]' \
'-z[end each output line with NUL, not newline, and disable file name escaping]' \
'--zero[end each output line with NUL, not newline, and disable file name escaping]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_b2sum" ]; then
    _b2sum "$@"
else
    compdef _b2sum b2sum
fi
