#compdef basenc

autoload -U is-at-least

_basenc() {
    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[@]}" : \
'-w+[wrap encoded lines after COLS character (default 76, 0 to disable wrapping)]:COLS:_default' \
'--wrap=[wrap encoded lines after COLS character (default 76, 0 to disable wrapping)]:COLS:_default' \
'-d[decode data]' \
'-D[decode data]' \
'--decode[decode data]' \
'-i[when decoding, ignore non-alphabetic characters]' \
'--ignore-garbage[when decoding, ignore non-alphabetic characters]' \
'--base64[same as '\''base64'\'' program]' \
'--base64url[file- and url-safe base64]' \
'--base32[same as '\''base32'\'' program]' \
'--base32hex[extended hex alphabet base32]' \
'--base16[hex encoding]' \
'--base2lsbf[bit string with least significant bit (lsb) first]' \
'--base2msbf[bit string with most significant bit (msb) first]' \
'--z85[ascii85-like encoding; when encoding, input length must be a multiple of 4; when decoding, input length must be a multiple of 5]' \
'--base58[visually unambiguous base58 encoding]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_basenc" ]; then
    _basenc "$@"
else
    compdef _basenc basenc
fi
