#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+[unexpand-help-tabs]:N, LIST:_default' \
'*--tabs=[unexpand-help-tabs]:N, LIST:_default' \
'-a[unexpand-help-all]' \
'--all[unexpand-help-all]' \
'-f[unexpand-help-first-only]' \
'--first-only[unexpand-help-first-only]' \
'-U[unexpand-help-no-utf8]' \
'--no-utf8[unexpand-help-no-utf8]' \
'-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
