#compdef uname

autoload -U is-at-least

_uname() {
    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[@]}" : \
'-a[uname-help-all]' \
'--all[uname-help-all]' \
'-s[uname-help-kernel-name]' \
'--kernel-name[uname-help-kernel-name]' \
'-n[uname-help-nodename]' \
'--nodename[uname-help-nodename]' \
'-r[uname-help-kernel-release]' \
'--kernel-release[uname-help-kernel-release]' \
'-v[uname-help-kernel-version]' \
'--kernel-version[uname-help-kernel-version]' \
'-m[uname-help-machine]' \
'--machine[uname-help-machine]' \
'-o[uname-help-os]' \
'--operating-system[uname-help-os]' \
'-p[uname-help-processor]' \
'--processor[uname-help-processor]' \
'-i[uname-help-hardware-platform]' \
'--hardware-platform[uname-help-hardware-platform]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_uname" ]; then
    _uname "$@"
else
    compdef _uname uname
fi
