#compdef anda

autoload -U is-at-least

_anda() {
    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 Andaman configuration file]:CONFIG:_files' \
'--config=[Path to Andaman configuration file]:CONFIG:_files' \
'-t+[Output directory for built packages]:TARGET_DIR:_files' \
'--target-dir=[Output directory for built packages]:TARGET_DIR:_files' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_anda_commands" \
"*::: :->anda" \
&& ret=0
    case $state in
    (anda)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:anda-command-$line[1]:"
        case $line[1] in
            (build)
_arguments "${_arguments_options[@]}" : \
'-p+[Builds a specific artifact format]:PACKAGE:(rpm docker podman flatpak all)' \
'--package=[Builds a specific artifact format]:PACKAGE:(rpm docker podman flatpak all)' \
'-r+[RPM\: Builder backend]:RPM_BUILDER:(mock rpmbuild)' \
'--rpm-builder=[RPM\: Builder backend]:RPM_BUILDER:(mock rpmbuild)' \
'*-D+[RPM\: Define a custom macro can be defined multiple times]:RPM_MACRO:_default' \
'*--rpm-macro=[RPM\: Define a custom macro can be defined multiple times]:RPM_MACRO:_default' \
'--rpm-target=[RPM\: A target to pass to rpmbuild/mock, useful for cross compilation]:RPM_TARGET:_default' \
'-c+[RPM\: Mock configuration]:MOCK_CONFIG:_default' \
'--mock-config=[RPM\: Mock configuration]:MOCK_CONFIG:_default' \
'*-R+[RPM\: Extra repositories to pass to mock]:EXTRA_REPOS:_default' \
'*--extra-repos=[RPM\: Extra repositories to pass to mock]:EXTRA_REPOS:_default' \
'*--extra-sources=[Flatpak\: Extra source directory can be defined multiple times]:EXTRA_SOURCES:_default' \
'*--extra-sources-url=[Flatpak\: Extra source URL can be defined multiple times]:EXTRA_SOURCES_URL:_default' \
'*--label=[OCI\: Labels to add to the image]:LABEL:_default' \
'*--build-arg=[OCI\: Build Arguments to pass to the build]:BUILD_ARG:_default' \
'-a[Builds all projects in the current directory]' \
'--all[Builds all projects in the current directory]' \
'--no-mirrors[RPM\: Do not mirror repositories]' \
'--dont-delete-build-dir[Flatpak\: Do not delete the build directory]' \
'--compress[OCI\: compress the context with gzip]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::project -- Project to build:_default' \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
'-y[Assume yes to all questions]' \
'--yes[Assume yes to all questions]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'::path -- Path to the project manifest:_files' \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
':shell -- Shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(ci)
_arguments "${_arguments_options[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
'*-l+[Labels to pass to the scripts]:LABELS:_default' \
'*--labels=[Labels to pass to the scripts]:LABELS:_default' \
'*-f+[Only run update scripts in project with the specified labels]:FILTERS:_default' \
'*--filters=[Only run update scripts in project with the specified labels]:FILTERS:_default' \
'*-e+[Exclude update scripts in project with the specified labels]:EXCLUDES:_default' \
'*--excludes=[Exclude update scripts in project with the specified labels]:EXCLUDES:_default' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::project:_default' \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" : \
'-l+[]:LABELS:_default' \
'--labels=[]:LABELS:_default' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'*::scripts:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_anda__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:anda-help-command-$line[1]:"
        case $line[1] in
            (build)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(ci)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_anda_commands] )) ||
_anda_commands() {
    local commands; commands=(
'build:Build a project' \
'clean:Cleans up the build directory' \
'list:Lists all projects in the manifest' \
'init:Initializes a new project manifest' \
'completion:Generate shell completions' \
'ci:Get CI output for Github Actions' \
'update:Update all projects' \
'run:Run .rhai scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'anda commands' commands "$@"
}
(( $+functions[_anda__subcmd__build_commands] )) ||
_anda__subcmd__build_commands() {
    local commands; commands=()
    _describe -t commands 'anda build commands' commands "$@"
}
(( $+functions[_anda__subcmd__ci_commands] )) ||
_anda__subcmd__ci_commands() {
    local commands; commands=()
    _describe -t commands 'anda ci commands' commands "$@"
}
(( $+functions[_anda__subcmd__clean_commands] )) ||
_anda__subcmd__clean_commands() {
    local commands; commands=()
    _describe -t commands 'anda clean commands' commands "$@"
}
(( $+functions[_anda__subcmd__completion_commands] )) ||
_anda__subcmd__completion_commands() {
    local commands; commands=()
    _describe -t commands 'anda completion commands' commands "$@"
}
(( $+functions[_anda__subcmd__help_commands] )) ||
_anda__subcmd__help_commands() {
    local commands; commands=(
'build:Build a project' \
'clean:Cleans up the build directory' \
'list:Lists all projects in the manifest' \
'init:Initializes a new project manifest' \
'completion:Generate shell completions' \
'ci:Get CI output for Github Actions' \
'update:Update all projects' \
'run:Run .rhai scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'anda help commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__build_commands] )) ||
_anda__subcmd__help__subcmd__build_commands() {
    local commands; commands=()
    _describe -t commands 'anda help build commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__ci_commands] )) ||
_anda__subcmd__help__subcmd__ci_commands() {
    local commands; commands=()
    _describe -t commands 'anda help ci commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__clean_commands] )) ||
_anda__subcmd__help__subcmd__clean_commands() {
    local commands; commands=()
    _describe -t commands 'anda help clean commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__completion_commands] )) ||
_anda__subcmd__help__subcmd__completion_commands() {
    local commands; commands=()
    _describe -t commands 'anda help completion commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__help_commands] )) ||
_anda__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'anda help help commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__init_commands] )) ||
_anda__subcmd__help__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'anda help init commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__list_commands] )) ||
_anda__subcmd__help__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'anda help list commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__run_commands] )) ||
_anda__subcmd__help__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'anda help run commands' commands "$@"
}
(( $+functions[_anda__subcmd__help__subcmd__update_commands] )) ||
_anda__subcmd__help__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'anda help update commands' commands "$@"
}
(( $+functions[_anda__subcmd__init_commands] )) ||
_anda__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'anda init commands' commands "$@"
}
(( $+functions[_anda__subcmd__list_commands] )) ||
_anda__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'anda list commands' commands "$@"
}
(( $+functions[_anda__subcmd__run_commands] )) ||
_anda__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'anda run commands' commands "$@"
}
(( $+functions[_anda__subcmd__update_commands] )) ||
_anda__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'anda update commands' commands "$@"
}

if [ "$funcstack[1]" = "_anda" ]; then
    _anda "$@"
else
    compdef _anda anda
fi
