#compdef mktemp

autoload -U is-at-least

_mktemp() {
    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[@]}" : \
'--suffix=[mktemp-help-suffix]:SUFFIX:_default' \
'-p+[mktemp-help-p]:DIR:_files -/' \
'--tmpdir=[mktemp-help-tmpdir]' \
'-d[mktemp-help-directory]' \
'--directory[mktemp-help-directory]' \
'-u[mktemp-help-dry-run]' \
'--dry-run[mktemp-help-dry-run]' \
'-q[mktemp-help-quiet]' \
'--quiet[mktemp-help-quiet]' \
'-t[mktemp-help-t]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::template:_default' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_mktemp" ]; then
    _mktemp "$@"
else
    compdef _mktemp mktemp
fi
