#compdef comtrya

autoload -U is-at-least

_comtrya() {
    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[@]}" : \
'-d+[]:MANIFEST_DIRECTORY:_default' \
'--manifest-directory=[]:MANIFEST_DIRECTORY:_default' \
'-c+[Specify a configuration path (if invalid Comtrya will exit)]:CONFIG_PATH:_default' \
'--config-path=[Specify a configuration path (if invalid Comtrya will exit)]:CONFIG_PATH:_default' \
'*-D+[]:DEFINES:_default' \
'*--defines=[]:DEFINES:_default' \
'--no-color[Disable color printing]' \
'*-v[Debug & tracing mode (-v, -vv)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_comtrya_commands" \
"*::: :->comtrya" \
&& ret=0
    case $state in
    (comtrya)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:comtrya-command-$line[1]:"
        case $line[1] in
            (apply)
_arguments "${_arguments_options[@]}" : \
'*-m+[Run a subset of your manifests, comma separated list. This should be a list of manifest names. No paths]:MANIFESTS:_default' \
'*--manifests=[Run a subset of your manifests, comma separated list. This should be a list of manifest names. No paths]:MANIFESTS:_default' \
'-l+[Define label selector]:LABEL:_default' \
'--label=[Define label selector]:LABEL:_default' \
'--dry-run[Performs a dry-run without changing the system]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'*-m+[Run a subset of your manifests, comma separated list. This should be a list of manifest names. No paths]:MANIFESTS:_default' \
'*--manifests=[Run a subset of your manifests, comma separated list. This should be a list of manifest names. No paths]:MANIFESTS:_default' \
'-l+[Define label selector]:LABEL:_default' \
'--label=[Define label selector]:LABEL:_default' \
'--dry-run[Performs a dry-run without changing the system]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(contexts)
_arguments "${_arguments_options[@]}" : \
'--show-values[Show the values of the contexts]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(gen-completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':shell -- If provided, outputs the completion file for given shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_comtrya__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:comtrya-help-command-$line[1]:"
        case $line[1] in
            (apply)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(contexts)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(gen-completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_comtrya_commands] )) ||
_comtrya_commands() {
    local commands; commands=(
'apply:Apply manifests' \
'status:List manifests status (ALPHA)' \
'version:Print version information' \
'contexts:List available contexts' \
'gen-completions:Auto generate completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'comtrya commands' commands "$@"
}
(( $+functions[_comtrya__apply_commands] )) ||
_comtrya__apply_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya apply commands' commands "$@"
}
(( $+functions[_comtrya__contexts_commands] )) ||
_comtrya__contexts_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya contexts commands' commands "$@"
}
(( $+functions[_comtrya__gen-completions_commands] )) ||
_comtrya__gen-completions_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya gen-completions commands' commands "$@"
}
(( $+functions[_comtrya__help_commands] )) ||
_comtrya__help_commands() {
    local commands; commands=(
'apply:Apply manifests' \
'status:List manifests status (ALPHA)' \
'version:Print version information' \
'contexts:List available contexts' \
'gen-completions:Auto generate completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'comtrya help commands' commands "$@"
}
(( $+functions[_comtrya__help__apply_commands] )) ||
_comtrya__help__apply_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help apply commands' commands "$@"
}
(( $+functions[_comtrya__help__contexts_commands] )) ||
_comtrya__help__contexts_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help contexts commands' commands "$@"
}
(( $+functions[_comtrya__help__gen-completions_commands] )) ||
_comtrya__help__gen-completions_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help gen-completions commands' commands "$@"
}
(( $+functions[_comtrya__help__help_commands] )) ||
_comtrya__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help help commands' commands "$@"
}
(( $+functions[_comtrya__help__status_commands] )) ||
_comtrya__help__status_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help status commands' commands "$@"
}
(( $+functions[_comtrya__help__version_commands] )) ||
_comtrya__help__version_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya help version commands' commands "$@"
}
(( $+functions[_comtrya__status_commands] )) ||
_comtrya__status_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya status commands' commands "$@"
}
(( $+functions[_comtrya__version_commands] )) ||
_comtrya__version_commands() {
    local commands; commands=()
    _describe -t commands 'comtrya version commands' commands "$@"
}

if [ "$funcstack[1]" = "_comtrya" ]; then
    _comtrya "$@"
else
    compdef _comtrya comtrya
fi
