#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+[base the size of each file on the size of RFILE]:RFILE:_files' \
'--reference=[base the size of each file on the size of RFILE]:RFILE:_files' \
'-s+[set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified]:SIZE:_default' \
'--size=[set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified]:SIZE:_default' \
'-o[treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)]' \
'--io-blocks[treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)]' \
'-c[do not create files that do not exist]' \
'--no-create[do not create files that do not exist]' \
'-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
