#compdef uu-uniq

autoload -U is-at-least

_uu-uniq() {
    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[@]}" : \
'-D+[print all duplicate lines. Delimiting is done with blank lines. \[default\: none\]]' \
'--all-repeated=[print all duplicate lines. Delimiting is done with blank lines. \[default\: none\]]' \
'(-d --repeated -D --all-repeated -u --unique -c --count)--group=[show all items, separating groups with an empty line. \[default\: separate\]]' \
'-w+[compare no more than N characters in lines]:N:_default' \
'--check-chars=[compare no more than N characters in lines]:N:_default' \
'-s+[avoid comparing the first N characters]:N:_default' \
'--skip-chars=[avoid comparing the first N characters]:N:_default' \
'-f+[avoid comparing the first N fields]:N:_default' \
'--skip-fields=[avoid comparing the first N fields]:N:_default' \
'-c[prefix lines by the number of occurrences]' \
'--count[prefix lines by the number of occurrences]' \
'-i[ignore differences in case when comparing]' \
'--ignore-case[ignore differences in case when comparing]' \
'-d[only print duplicate lines]' \
'--repeated[only print duplicate lines]' \
'-u[only print unique lines]' \
'--unique[only print unique lines]' \
'-z[end lines with 0 byte, not newline]' \
'--zero-terminated[end lines with 0 byte, not newline]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
}

(( $+functions[_uu-uniq_commands] )) ||
_uu-uniq_commands() {
    local commands; commands=()
    _describe -t commands 'uu-uniq commands' commands "$@"
}

if [ "$funcstack[1]" = "_uu-uniq" ]; then
    _uu-uniq "$@"
else
    compdef _uu-uniq uu-uniq
fi
