#compdef base64

autoload -U is-at-least

_base64() {
    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+[base-common-help-wrap]:COLS:_default' \
'--wrap=[base-common-help-wrap]:COLS:_default' \
'-d[base-common-help-decode]' \
'-D[base-common-help-decode]' \
'--decode[base-common-help-decode]' \
'-i[base-common-help-ignore-garbage]' \
'--ignore-garbage[base-common-help-ignore-garbage]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_base64" ]; then
    _base64 "$@"
else
    compdef _base64 base64
fi
