#compdef shred

autoload -U is-at-least

_shred() {
    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[@]}" : \
'-n+[shred-iterations-help]:NUMBER:_default' \
'--iterations=[shred-iterations-help]:NUMBER:_default' \
'-s+[shred-size-help]:N:_default' \
'--size=[shred-size-help]:N:_default' \
'--remove=[shred-remove-help]' \
'--random-source=[shred-random-source-help]: :_files' \
'-f[shred-force-help]' \
'--force[shred-force-help]' \
'-u[shred-deallocate-help]' \
'-v[shred-verbose-help]' \
'--verbose[shred-verbose-help]' \
'-x[shred-exact-help]' \
'--exact[shred-exact-help]' \
'-z[shred-zero-help]' \
'--zero[shred-zero-help]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_shred" ]; then
    _shred "$@"
else
    compdef _shred shred
fi
