#compdef expand

autoload -U is-at-least

_expand() {
    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+[have tabs N characters apart, not 8 or use comma separated list of explicit tab positions]:N, LIST:_default' \
'*--tabs=[have tabs N characters apart, not 8 or use comma separated list of explicit tab positions]:N, LIST:_default' \
'-i[do not convert tabs after non blanks]' \
'--initial[do not convert tabs after non blanks]' \
'-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]' \
'::FILES:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_expand" ]; then
    _expand "$@"
else
    compdef _expand expand
fi
