#compdef ciel

autoload -U is-at-least

_ciel() {
    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+[Set the CIEL! working directory]:DIR: ' \
'-b[Batch mode, no input required]' \
'--batch[Batch mode, no input required]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
":: :_ciel_commands" \
"*::: :->ciel" \
&& ret=0
    case $state in
    (ciel)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ciel-command-$line[1]:"
        case $line[1] in
            (version)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
'--upgrade[Upgrade Ciel workspace from an older version]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(load-os)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::url -- URL or path to the tarball:' \
&& ret=0
;;
(update-os)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(load-tree)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::url -- URL to the git repository:' \
&& ret=0
;;
(update-tree)
_arguments "${_arguments_options[@]}" \
'-r+[Rebase the specified branch from the updated upstream]: : ' \
'--rebase=[Rebase the specified branch from the updated upstream]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
'::branch -- Branch to switch to:' \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" \
'--from-tarball=[Create a new workspace from the specified tarball]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(add)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':INSTANCE:' \
&& ret=0
;;
(del)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':INSTANCE:' \
&& ret=0
;;
(shell)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be used]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::COMMANDS:' \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to run command in]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::COMMANDS:' \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be configured]: : ' \
'(-i)-g[Configure base system instead of an instance]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(commit)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be committed]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(doctor)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(build)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to build in]: : ' \
'(--stage-select)-c+[Continue from a Ciel checkpoint]: : ' \
'(--stage-select)--resume=[Continue from a Ciel checkpoint]: : ' \
'*--with-topics=[Try to add topics before building, delimited by space]: : ' \
'--stage-select=[Select the starting point for a build]' \
'-g[Fetch source packages only]' \
'-x[Disable network in the container during the build]' \
'--offline[Disable network in the container during the build]' \
'-2[Use stage 2 mode instead of the regular build mode]' \
'--stage2[Use stage 2 mode instead of the regular build mode]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::PACKAGES:' \
&& ret=0
;;
(rollback)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be rolled back]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(down)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be un-mounted]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(stop)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be stopped]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(mount)
_arguments "${_arguments_options[@]}" \
'-i+[Instance to be mounted]: : ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(farewell)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(repo)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_ciel__repo_commands" \
"*::: :->repo" \
&& ret=0

    case $state in
    (repo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ciel-repo-command-$line[1]:"
        case $line[1] in
            (refresh)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':INSTANCE:' \
&& ret=0
;;
(deinit)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ciel__repo__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ciel-repo-help-command-$line[1]:"
        case $line[1] in
            (refresh)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(deinit)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(clean)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ciel__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ciel-help-command-$line[1]:"
        case $line[1] in
            (version)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(load-os)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(update-os)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(load-tree)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(update-tree)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(add)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(del)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(shell)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(commit)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(doctor)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(build)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(rollback)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(down)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(stop)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(mount)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(farewell)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(repo)
_arguments "${_arguments_options[@]}" \
":: :_ciel__help__repo_commands" \
"*::: :->repo" \
&& ret=0

    case $state in
    (repo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ciel-help-repo-command-$line[1]:"
        case $line[1] in
            (refresh)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(deinit)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
(clean)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_ciel_commands] )) ||
_ciel_commands() {
    local commands; commands=(
'version:Display the version of CIEL!' \
'init:Initialize the work directory' \
'load-os:Unpack OS tarball or fetch the latest BuildKit from the repository' \
'update-os:Update the OS in the container' \
'load-tree:Clone package tree from the link provided or AOSC OS ABBS main repository' \
'update-tree:Update the existing ABBS tree (fetch only) and optionally switch to a different branch' \
'new:Create a new CIEL workspace' \
'list:List all the instances under the specified working directory' \
'add:Add a new instance' \
'del:Remove an instance' \
'shell:Start an interactive shell' \
'run:Lower-level version of '\''shell'\'', without login environment, without sourcing ~/.bash_profile' \
'config:Configure system and toolchain for building interactively' \
'commit:Commit changes onto the shared underlying OS' \
'doctor:Diagnose problems (hopefully)' \
'build:Build the packages using the specified instance' \
'rollback:Rollback all or specified instance' \
'down:Shutdown and unmount all or one instance' \
'stop:Shuts down an instance' \
'mount:Mount all or specified instance' \
'farewell:Remove everything related to CIEL!' \
'repo:Local repository operations' \
'clean:Clean all the output directories and source cache directories' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ciel commands' commands "$@"
}
(( $+functions[_ciel__add_commands] )) ||
_ciel__add_commands() {
    local commands; commands=()
    _describe -t commands 'ciel add commands' commands "$@"
}
(( $+functions[_ciel__help__add_commands] )) ||
_ciel__help__add_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help add commands' commands "$@"
}
(( $+functions[_ciel__build_commands] )) ||
_ciel__build_commands() {
    local commands; commands=()
    _describe -t commands 'ciel build commands' commands "$@"
}
(( $+functions[_ciel__help__build_commands] )) ||
_ciel__help__build_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help build commands' commands "$@"
}
(( $+functions[_ciel__clean_commands] )) ||
_ciel__clean_commands() {
    local commands; commands=()
    _describe -t commands 'ciel clean commands' commands "$@"
}
(( $+functions[_ciel__help__clean_commands] )) ||
_ciel__help__clean_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help clean commands' commands "$@"
}
(( $+functions[_ciel__commit_commands] )) ||
_ciel__commit_commands() {
    local commands; commands=()
    _describe -t commands 'ciel commit commands' commands "$@"
}
(( $+functions[_ciel__help__commit_commands] )) ||
_ciel__help__commit_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help commit commands' commands "$@"
}
(( $+functions[_ciel__config_commands] )) ||
_ciel__config_commands() {
    local commands; commands=()
    _describe -t commands 'ciel config commands' commands "$@"
}
(( $+functions[_ciel__help__config_commands] )) ||
_ciel__help__config_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help config commands' commands "$@"
}
(( $+functions[_ciel__help__repo__deinit_commands] )) ||
_ciel__help__repo__deinit_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help repo deinit commands' commands "$@"
}
(( $+functions[_ciel__repo__deinit_commands] )) ||
_ciel__repo__deinit_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo deinit commands' commands "$@"
}
(( $+functions[_ciel__repo__help__deinit_commands] )) ||
_ciel__repo__help__deinit_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo help deinit commands' commands "$@"
}
(( $+functions[_ciel__del_commands] )) ||
_ciel__del_commands() {
    local commands; commands=()
    _describe -t commands 'ciel del commands' commands "$@"
}
(( $+functions[_ciel__help__del_commands] )) ||
_ciel__help__del_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help del commands' commands "$@"
}
(( $+functions[_ciel__doctor_commands] )) ||
_ciel__doctor_commands() {
    local commands; commands=()
    _describe -t commands 'ciel doctor commands' commands "$@"
}
(( $+functions[_ciel__help__doctor_commands] )) ||
_ciel__help__doctor_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help doctor commands' commands "$@"
}
(( $+functions[_ciel__down_commands] )) ||
_ciel__down_commands() {
    local commands; commands=()
    _describe -t commands 'ciel down commands' commands "$@"
}
(( $+functions[_ciel__help__down_commands] )) ||
_ciel__help__down_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help down commands' commands "$@"
}
(( $+functions[_ciel__farewell_commands] )) ||
_ciel__farewell_commands() {
    local commands; commands=()
    _describe -t commands 'ciel farewell commands' commands "$@"
}
(( $+functions[_ciel__help__farewell_commands] )) ||
_ciel__help__farewell_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help farewell commands' commands "$@"
}
(( $+functions[_ciel__help_commands] )) ||
_ciel__help_commands() {
    local commands; commands=(
'version:Display the version of CIEL!' \
'init:Initialize the work directory' \
'load-os:Unpack OS tarball or fetch the latest BuildKit from the repository' \
'update-os:Update the OS in the container' \
'load-tree:Clone package tree from the link provided or AOSC OS ABBS main repository' \
'update-tree:Update the existing ABBS tree (fetch only) and optionally switch to a different branch' \
'new:Create a new CIEL workspace' \
'list:List all the instances under the specified working directory' \
'add:Add a new instance' \
'del:Remove an instance' \
'shell:Start an interactive shell' \
'run:Lower-level version of '\''shell'\'', without login environment, without sourcing ~/.bash_profile' \
'config:Configure system and toolchain for building interactively' \
'commit:Commit changes onto the shared underlying OS' \
'doctor:Diagnose problems (hopefully)' \
'build:Build the packages using the specified instance' \
'rollback:Rollback all or specified instance' \
'down:Shutdown and unmount all or one instance' \
'stop:Shuts down an instance' \
'mount:Mount all or specified instance' \
'farewell:Remove everything related to CIEL!' \
'repo:Local repository operations' \
'clean:Clean all the output directories and source cache directories' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ciel help commands' commands "$@"
}
(( $+functions[_ciel__help__help_commands] )) ||
_ciel__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help help commands' commands "$@"
}
(( $+functions[_ciel__repo__help_commands] )) ||
_ciel__repo__help_commands() {
    local commands; commands=(
'refresh:Refresh the repository' \
'init:Initialize the repository' \
'deinit:Uninitialize the repository' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ciel repo help commands' commands "$@"
}
(( $+functions[_ciel__repo__help__help_commands] )) ||
_ciel__repo__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo help help commands' commands "$@"
}
(( $+functions[_ciel__help__init_commands] )) ||
_ciel__help__init_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help init commands' commands "$@"
}
(( $+functions[_ciel__help__repo__init_commands] )) ||
_ciel__help__repo__init_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help repo init commands' commands "$@"
}
(( $+functions[_ciel__init_commands] )) ||
_ciel__init_commands() {
    local commands; commands=()
    _describe -t commands 'ciel init commands' commands "$@"
}
(( $+functions[_ciel__repo__help__init_commands] )) ||
_ciel__repo__help__init_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo help init commands' commands "$@"
}
(( $+functions[_ciel__repo__init_commands] )) ||
_ciel__repo__init_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo init commands' commands "$@"
}
(( $+functions[_ciel__help__list_commands] )) ||
_ciel__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help list commands' commands "$@"
}
(( $+functions[_ciel__list_commands] )) ||
_ciel__list_commands() {
    local commands; commands=()
    _describe -t commands 'ciel list commands' commands "$@"
}
(( $+functions[_ciel__help__load-os_commands] )) ||
_ciel__help__load-os_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help load-os commands' commands "$@"
}
(( $+functions[_ciel__load-os_commands] )) ||
_ciel__load-os_commands() {
    local commands; commands=()
    _describe -t commands 'ciel load-os commands' commands "$@"
}
(( $+functions[_ciel__help__load-tree_commands] )) ||
_ciel__help__load-tree_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help load-tree commands' commands "$@"
}
(( $+functions[_ciel__load-tree_commands] )) ||
_ciel__load-tree_commands() {
    local commands; commands=()
    _describe -t commands 'ciel load-tree commands' commands "$@"
}
(( $+functions[_ciel__help__mount_commands] )) ||
_ciel__help__mount_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help mount commands' commands "$@"
}
(( $+functions[_ciel__mount_commands] )) ||
_ciel__mount_commands() {
    local commands; commands=()
    _describe -t commands 'ciel mount commands' commands "$@"
}
(( $+functions[_ciel__help__new_commands] )) ||
_ciel__help__new_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help new commands' commands "$@"
}
(( $+functions[_ciel__new_commands] )) ||
_ciel__new_commands() {
    local commands; commands=()
    _describe -t commands 'ciel new commands' commands "$@"
}
(( $+functions[_ciel__help__repo__refresh_commands] )) ||
_ciel__help__repo__refresh_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help repo refresh commands' commands "$@"
}
(( $+functions[_ciel__repo__help__refresh_commands] )) ||
_ciel__repo__help__refresh_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo help refresh commands' commands "$@"
}
(( $+functions[_ciel__repo__refresh_commands] )) ||
_ciel__repo__refresh_commands() {
    local commands; commands=()
    _describe -t commands 'ciel repo refresh commands' commands "$@"
}
(( $+functions[_ciel__help__repo_commands] )) ||
_ciel__help__repo_commands() {
    local commands; commands=(
'refresh:Refresh the repository' \
'init:Initialize the repository' \
'deinit:Uninitialize the repository' \
    )
    _describe -t commands 'ciel help repo commands' commands "$@"
}
(( $+functions[_ciel__repo_commands] )) ||
_ciel__repo_commands() {
    local commands; commands=(
'refresh:Refresh the repository' \
'init:Initialize the repository' \
'deinit:Uninitialize the repository' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ciel repo commands' commands "$@"
}
(( $+functions[_ciel__help__rollback_commands] )) ||
_ciel__help__rollback_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help rollback commands' commands "$@"
}
(( $+functions[_ciel__rollback_commands] )) ||
_ciel__rollback_commands() {
    local commands; commands=()
    _describe -t commands 'ciel rollback commands' commands "$@"
}
(( $+functions[_ciel__help__run_commands] )) ||
_ciel__help__run_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help run commands' commands "$@"
}
(( $+functions[_ciel__run_commands] )) ||
_ciel__run_commands() {
    local commands; commands=()
    _describe -t commands 'ciel run commands' commands "$@"
}
(( $+functions[_ciel__help__shell_commands] )) ||
_ciel__help__shell_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help shell commands' commands "$@"
}
(( $+functions[_ciel__shell_commands] )) ||
_ciel__shell_commands() {
    local commands; commands=()
    _describe -t commands 'ciel shell commands' commands "$@"
}
(( $+functions[_ciel__help__stop_commands] )) ||
_ciel__help__stop_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help stop commands' commands "$@"
}
(( $+functions[_ciel__stop_commands] )) ||
_ciel__stop_commands() {
    local commands; commands=()
    _describe -t commands 'ciel stop commands' commands "$@"
}
(( $+functions[_ciel__help__update-os_commands] )) ||
_ciel__help__update-os_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help update-os commands' commands "$@"
}
(( $+functions[_ciel__update-os_commands] )) ||
_ciel__update-os_commands() {
    local commands; commands=()
    _describe -t commands 'ciel update-os commands' commands "$@"
}
(( $+functions[_ciel__help__update-tree_commands] )) ||
_ciel__help__update-tree_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help update-tree commands' commands "$@"
}
(( $+functions[_ciel__update-tree_commands] )) ||
_ciel__update-tree_commands() {
    local commands; commands=()
    _describe -t commands 'ciel update-tree commands' commands "$@"
}
(( $+functions[_ciel__help__version_commands] )) ||
_ciel__help__version_commands() {
    local commands; commands=()
    _describe -t commands 'ciel help version commands' commands "$@"
}
(( $+functions[_ciel__version_commands] )) ||
_ciel__version_commands() {
    local commands; commands=()
    _describe -t commands 'ciel version commands' commands "$@"
}

_ciel "$@"
