#compdef runcon

autoload -U is-at-least

_runcon() {
    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[@]}" : \
'-u+[runcon-help-user]:USER:_default' \
'--user=[runcon-help-user]:USER:_default' \
'-r+[runcon-help-role]:ROLE:_default' \
'--role=[runcon-help-role]:ROLE:_default' \
'-t+[runcon-help-type]:TYPE:_default' \
'--type=[runcon-help-type]:TYPE:_default' \
'-l+[runcon-help-range]:RANGE:_default' \
'--range=[runcon-help-range]:RANGE:_default' \
'-c[runcon-help-compute]' \
'--compute[runcon-help-compute]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::ARG:_command_names -e' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_runcon" ]; then
    _runcon "$@"
else
    compdef _runcon runcon
fi
