#compdef truncate

autoload -U is-at-least

_truncate() {
    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[@]}" : \
'-r+[truncate-help-reference]:RFILE:_files' \
'--reference=[truncate-help-reference]:RFILE:_files' \
'-s+[truncate-help-size]:SIZE:_default' \
'--size=[truncate-help-size]:SIZE:_default' \
'-o[truncate-help-io-blocks]' \
'--io-blocks[truncate-help-io-blocks]' \
'-c[truncate-help-no-create]' \
'--no-create[truncate-help-no-create]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_truncate" ]; then
    _truncate "$@"
else
    compdef _truncate truncate
fi
