#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: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
":: :_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: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
&& 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: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
&& 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: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
&& 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: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
&& ret=0
;;
(help)
_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: ' \
'-s[Select a task to run]' \
'--select[Select a task to run]' \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        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=()
    _describe -t commands 'machine_setup help 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__list_commands] )) ||
_machine_setup__list_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup list 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__update_commands] )) ||
_machine_setup__update_commands() {
    local commands; commands=()
    _describe -t commands 'machine_setup update commands' commands "$@"
}

_machine_setup "$@"
