#compdef ayllu-build

autoload -U is-at-least

_ayllu-build() {
    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 your configuration file]:FILE:_files' \
'--config=[Path to your configuration file]:FILE:_files' \
'-l+[Sets the logging level]:LEVEL:_default' \
'--level=[Sets the logging level]:LEVEL:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_ayllu-build_commands" \
"*::: :->ayllu-build" \
&& ret=0
    case $state in
    (ayllu-build)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ayllu-build-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::source -- Build Source can be PATH or collection/name:_default' \
&& ret=0
;;
(evaluate)
_arguments "${_arguments_options[@]}" : \
'-n+[Unique build name]:NAME:_default' \
'--name=[Unique build name]:NAME:_default' \
'-f[If the standard streams should be forwarded to the terminal]' \
'--forward[If the standard streams should be forwarded to the terminal]' \
'-s[Read the collection / name from stdin]' \
'--stdin[Read the collection / name from stdin]' \
'-d[Pause on step failures so you can attach to the environment]' \
'--debug[Pause on step failures so you can attach to the environment]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::source -- Build Source can be - for STDIN, PATH, or collection/name:_default' \
&& ret=0
;;
(listen)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(shell)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':manifest_id -- Manifest identifier:_default' \
':workflow_id -- Workflow identifier:_default' \
&& ret=0
;;
(ps)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(gc)
_arguments "${_arguments_options[@]}" : \
'-t+[Number of milliseconds to wait before sending SIGKILL]:TIMEOUT:_default' \
'--timeout=[Number of milliseconds to wait before sending SIGKILL]:TIMEOUT:_default' \
'-f[Force the clean-up of all containers regardless of their status]' \
'--force[Force the clean-up of all containers regardless of their status]' \
'-w[Delete the runtime directory of the container (DESTRUCTIVE)]' \
'--workspace[Delete the runtime directory of the container (DESTRUCTIVE)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_ayllu-build__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ayllu-build-help-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(evaluate)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(listen)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(shell)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(ps)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(gc)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_ayllu-build_commands] )) ||
_ayllu-build_commands() {
    local commands; commands=(
'check:Check the build configuration' \
'evaluate:Evaluate a local build script' \
'listen:Listen for new build requests' \
'shell:Launch a shell session for debugging purposes' \
'ps:List active build processes' \
'gc:Garbage collect old builds' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ayllu-build commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__check_commands] )) ||
_ayllu-build__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build check commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__evaluate_commands] )) ||
_ayllu-build__subcmd__evaluate_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build evaluate commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__gc_commands] )) ||
_ayllu-build__subcmd__gc_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build gc commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help_commands] )) ||
_ayllu-build__subcmd__help_commands() {
    local commands; commands=(
'check:Check the build configuration' \
'evaluate:Evaluate a local build script' \
'listen:Listen for new build requests' \
'shell:Launch a shell session for debugging purposes' \
'ps:List active build processes' \
'gc:Garbage collect old builds' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ayllu-build help commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__check_commands] )) ||
_ayllu-build__subcmd__help__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help check commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__evaluate_commands] )) ||
_ayllu-build__subcmd__help__subcmd__evaluate_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help evaluate commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__gc_commands] )) ||
_ayllu-build__subcmd__help__subcmd__gc_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help gc commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__help_commands] )) ||
_ayllu-build__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help help commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__listen_commands] )) ||
_ayllu-build__subcmd__help__subcmd__listen_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help listen commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__ps_commands] )) ||
_ayllu-build__subcmd__help__subcmd__ps_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help ps commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__help__subcmd__shell_commands] )) ||
_ayllu-build__subcmd__help__subcmd__shell_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build help shell commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__listen_commands] )) ||
_ayllu-build__subcmd__listen_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build listen commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__ps_commands] )) ||
_ayllu-build__subcmd__ps_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build ps commands' commands "$@"
}
(( $+functions[_ayllu-build__subcmd__shell_commands] )) ||
_ayllu-build__subcmd__shell_commands() {
    local commands; commands=()
    _describe -t commands 'ayllu-build shell commands' commands "$@"
}

if [ "$funcstack[1]" = "_ayllu-build" ]; then
    _ayllu-build "$@"
else
    compdef _ayllu-build ayllu-build
fi
