#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+[Set user USER in the target security context.]:USER:_default' \
'--user=[Set user USER in the target security context.]:USER:_default' \
'-r+[Set role ROLE in the target security context.]:ROLE:_default' \
'--role=[Set role ROLE in the target security context.]:ROLE:_default' \
'-t+[Set type TYPE in the target security context.]:TYPE:_default' \
'--type=[Set type TYPE in the target security context.]:TYPE:_default' \
'-l+[Set range RANGE in the target security context.]:RANGE:_default' \
'--range=[Set range RANGE in the target security context.]:RANGE:_default' \
'-c[Compute process transition context before modifying.]' \
'--compute[Compute process transition context before modifying.]' \
'-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
