#compdef machine_setup

autoload -U is-at-least

_machine_setup() {
    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[@]}" \
'-c+[path to the config file]:CONFIG: ' \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_machine_setup_commands" \
"*::: :->machine_setup" \
&& ret=0
    case $state in
    (machine_setup)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:machine_setup-command-$line[1]:"
        case $line[1] in
            (install)
_arguments "${_arguments_options[@]}" \
'-c+[path to the config file]:CONFIG: ' \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" \
'-c+[path to the config file]:CONFIG: ' \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(uninstall)
_arguments "${_arguments_options[@]}" \
'-c+[path to the config file]:CONFIG: ' \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" \
'-c+[path to the config file]:CONFIG: ' \
'--config=[path to the config file]:CONFIG: ' \
'-t+[run a single task]:TASK: ' \
'--task=[run a single task]:TASK: ' \
'-l+[Set log level]:LEVEL: ' \
'--level=[Set log level]:LEVEL: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'-d[Add debug information]' \
'--debug[Add debug information]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_machine_setup__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:machine_setup-help-command-$line[1]:"
        case $line[1] in
            (install)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(uninstall)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_machine_setup_commands] )) ||
_machine_setup_commands() {
    local commands; commands=(
'install:Install all of the defined tasks' \
'update:Update all of the defined tasks' \
'uninstall:Uninstall all of the defined tasks' \
'list:List defined tasks' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'machine_setup commands' commands "$@"
}
(( $+functions[_machine_setup__help_commands] )) ||
_machine_setup__help_commands() {
    local commands; commands=(
'install:Install all of the defined tasks' \
'update:Update all of the defined tasks' \
'uninstall:Uninstall all of the defined tasks' \
'list:List defined tasks' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'machine_setup help commands' commands "$@"
}
(( $+functions[_machine_setup__help__help_commands] )) ||
_machine_setup__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup help help commands' commands "$@"
}
(( $+functions[_machine_setup__help__install_commands] )) ||
_machine_setup__help__install_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup help install commands' commands "$@"
}
(( $+functions[_machine_setup__install_commands] )) ||
_machine_setup__install_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup install commands' commands "$@"
}
(( $+functions[_machine_setup__help__list_commands] )) ||
_machine_setup__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup help list commands' commands "$@"
}
(( $+functions[_machine_setup__list_commands] )) ||
_machine_setup__list_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup list commands' commands "$@"
}
(( $+functions[_machine_setup__help__uninstall_commands] )) ||
_machine_setup__help__uninstall_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup help uninstall commands' commands "$@"
}
(( $+functions[_machine_setup__uninstall_commands] )) ||
_machine_setup__uninstall_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup uninstall commands' commands "$@"
}
(( $+functions[_machine_setup__help__update_commands] )) ||
_machine_setup__help__update_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup help update commands' commands "$@"
}
(( $+functions[_machine_setup__update_commands] )) ||
_machine_setup__update_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup update commands' commands "$@"
}

if [ "$funcstack[1]" = "_machine_setup" ]; then
    _machine_setup "$@"
else
    compdef _machine_setup machine_setup
fi
