#compdef topgrade

autoload -U is-at-least

_topgrade() {
    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[@]}" : \
'*--disable=[Do not perform upgrades for the given steps]:STEP:(am android_studio app_man aqua asdf atom audit auto_cpufreq bin bob brew_cask brew_formula bun bun_packages cargo certbot chezmoi chocolatey choosenim cinnamon_spices clam_av_db composer conda config_update containers custom_commands deb_get deno distrobox dkp_pacman dotnet elan emacs firmware flatpak flutter fossil gcloud gem ghcup git_repos github_cli_extensions gnome_shell_extensions go guix haxelib helix helm home_manager jetbrains_aqua jetbrains_clion jetbrains_datagrip jetbrains_dataspell jetbrains_gateway jetbrains_goland jetbrains_idea jetbrains_mps jetbrains_phpstorm jetbrains_pycharm jetbrains_rider jetbrains_rubymine jetbrains_rustrover jetbrains_toolbox jetbrains_webstorm jetpack julia juliaup kakoune krew lensfun lure macports mamba mas maza micro microsoft_store miktex mise myrepos nix node opam pacdef pacstall pearl pip3 pip_review pip_review_local pipupgrade pipx pipxu pixi pkg pkgin platformio_core pnpm poetry powershell protonup pyenv raco rcm remotes restarts rtcl ruby_gems rustup rye scoop sdkman self_update sheldon shell snap sparkle spicetify stack stew system tldr tlmgr tmux toolbx uv vagrant vcpkg vim volta_packages vscode vscodium waydroid winget wsl wsl_update xcodes yadm yarn yazi zigup zvm)' \
'*--only=[Perform only the specified steps]:STEP:(am android_studio app_man aqua asdf atom audit auto_cpufreq bin bob brew_cask brew_formula bun bun_packages cargo certbot chezmoi chocolatey choosenim cinnamon_spices clam_av_db composer conda config_update containers custom_commands deb_get deno distrobox dkp_pacman dotnet elan emacs firmware flatpak flutter fossil gcloud gem ghcup git_repos github_cli_extensions gnome_shell_extensions go guix haxelib helix helm home_manager jetbrains_aqua jetbrains_clion jetbrains_datagrip jetbrains_dataspell jetbrains_gateway jetbrains_goland jetbrains_idea jetbrains_mps jetbrains_phpstorm jetbrains_pycharm jetbrains_rider jetbrains_rubymine jetbrains_rustrover jetbrains_toolbox jetbrains_webstorm jetpack julia juliaup kakoune krew lensfun lure macports mamba mas maza micro microsoft_store miktex mise myrepos nix node opam pacdef pacstall pearl pip3 pip_review pip_review_local pipupgrade pipx pipxu pixi pkg pkgin platformio_core pnpm poetry powershell protonup pyenv raco rcm remotes restarts rtcl ruby_gems rustup rye scoop sdkman self_update sheldon shell snap sparkle spicetify stack stew system tldr tlmgr tmux toolbx uv vagrant vcpkg vim volta_packages vscode vscodium waydroid winget wsl wsl_update xcodes yadm yarn yazi zigup zvm)' \
'*--custom-commands=[Run only specific custom commands]:NAME: ' \
'*--env=[Set environment variables]:NAME=VALUE: ' \
'*-y+[Say yes to package manager'\''s prompt]' \
'*--yes=[Say yes to package manager'\''s prompt]' \
'--config=[Alternative configuration file]:PATH:_files' \
'--remote-host-limit=[A regular expression for restricting remote host execution]:REGEX: ' \
'--log-filter=[Tracing filter directives]:LOG_FILTER: ' \
'--gen-completion=[Print completion script for the given shell and exit]:GEN_COMPLETION:(bash elvish fish powershell zsh)' \
'--edit-config[Edit the configuration file]' \
'--config-reference[Show config reference]' \
'-t[Run inside tmux]' \
'--tmux[Run inside tmux]' \
'-c[Cleanup temporary or old files]' \
'--cleanup[Cleanup temporary or old files]' \
'-n[Print what would be done]' \
'--dry-run[Print what would be done]' \
'--no-retry[Do not ask to retry failed steps]' \
'-v[Output debug logs. Alias for \`--log-filter debug\`]' \
'--verbose[Output debug logs. Alias for \`--log-filter debug\`]' \
'-k[Prompt for a key before exiting]' \
'--keep[Prompt for a key before exiting]' \
'--skip-notify[Skip sending a notification at the end of a run]' \
'--disable-predefined-git-repos[Don'\''t pull the predefined git repos]' \
'--show-skipped[Show the reason for skipped steps]' \
'--gen-manpage[Print roff manpage and exit]' \
'--no-self-update[Don'\''t update Topgrade]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

(( $+functions[_topgrade_commands] )) ||
_topgrade_commands() {
    local commands; commands=()
    _describe -t commands 'topgrade commands' commands "$@"
}

if [ "$funcstack[1]" = "_topgrade" ]; then
    _topgrade "$@"
else
    compdef _topgrade topgrade
fi
