#compdef wc

autoload -U is-at-least

_wc() {
    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[@]}" : \
'--files0-from=[wc-help-files0-from]:F:_files' \
'--total=[wc-help-total]:WHEN:(auto always only never)' \
'-c[wc-help-bytes]' \
'--bytes[wc-help-bytes]' \
'-m[wc-help-chars]' \
'--chars[wc-help-chars]' \
'-l[wc-help-lines]' \
'--lines[wc-help-lines]' \
'-L[wc-help-max-line-length]' \
'--max-line-length[wc-help-max-line-length]' \
'-w[wc-help-words]' \
'--words[wc-help-words]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_wc" ]; then
    _wc "$@"
else
    compdef _wc wc
fi
