#compdef unexpand

autoload -U is-at-least

_unexpand() {
    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[@]}" : \
'*-t+[use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)]:N, LIST:_default' \
'*--tabs=[use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)]:N, LIST:_default' \
'-a[convert all blanks, instead of just initial blanks]' \
'--all[convert all blanks, instead of just initial blanks]' \
'-f[convert only leading sequences of blanks (overrides -a)]' \
'--first-only[convert only leading sequences of blanks (overrides -a)]' \
'-U[interpret input file as 8-bit ASCII rather than UTF-8]' \
'--no-utf8[interpret input file as 8-bit ASCII rather than UTF-8]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_unexpand" ]; then
    _unexpand "$@"
else
    compdef _unexpand unexpand
fi
