#compdef rtx
_rtx() {
	typeset -A opt_args
	local context state line curcontext=$curcontext
	local ret=1

	_arguments -s -S \
		'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
		'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
		'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
		'*'{-v,--verbose}'[Show installation output]' \
		'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
		'1: :__rtx_cmds' \
		'*::arg:->args' && ret=0

	case "$state" in
	args)
		curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
		case $words[1] in
		activate) __rtx_activate_cmd && ret=0 ;;
		a | aliases | alias) __rtx_alias_cmd && ret=0 ;;
		asdf) __rtx_asdf_cmd && ret=0 ;;
		bin-paths) __rtx_bin_paths_cmd && ret=0 ;;
		cache) __rtx_cache_cmd && ret=0 ;;
		complete | completions | completion) __rtx_completion_cmd && ret=0 ;;
		current) __rtx_current_cmd && ret=0 ;;
		deactivate) __rtx_deactivate_cmd && ret=0 ;;
		direnv) __rtx_direnv_cmd && ret=0 ;;
		doctor) __rtx_doctor_cmd && ret=0 ;;
		e | env) __rtx_env_cmd && ret=0 ;;
		env-vars) __rtx_env_vars_cmd && ret=0 ;;
		x | exec) __rtx_exec_cmd && ret=0 ;;
		g | global) __rtx_global_cmd && ret=0 ;;
		hook-env) __rtx_hook_env_cmd && ret=0 ;;
		implode) __rtx_implode_cmd && ret=0 ;;
		i | install) __rtx_install_cmd && ret=0 ;;
		latest) __rtx_latest_cmd && ret=0 ;;
		link) __rtx_link_cmd && ret=0 ;;
		l | local) __rtx_local_cmd && ret=0 ;;
		list | ls) __rtx_ls_cmd && ret=0 ;;
		list-all | list-remote | ls-remote) __rtx_ls_remote_cmd && ret=0 ;;
		outdated) __rtx_outdated_cmd && ret=0 ;;
		p | plugin | plugin-list | plugins) __rtx_plugins_cmd && ret=0 ;;
		prune) __rtx_prune_cmd && ret=0 ;;
		reshim) __rtx_reshim_cmd && ret=0 ;;
		self-update) __rtx_self_update_cmd && ret=0 ;;
		settings) __rtx_settings_cmd && ret=0 ;;
		s | shell) __rtx_shell_cmd && ret=0 ;;
		sync) __rtx_sync_cmd && ret=0 ;;
		trust) __rtx_trust_cmd && ret=0 ;;
		remove | rm | uninstall) __rtx_uninstall_cmd && ret=0 ;;
		upgrade) __rtx_upgrade_cmd && ret=0 ;;
		u | use) __rtx_use_cmd && ret=0 ;;
		v | version) __rtx_version_cmd && ret=0 ;;
		where) __rtx_where_cmd && ret=0 ;;
		which) __rtx_which_cmd && ret=0 ;;
		esac
		;;
	esac

	return ret
}
(($ + functions[__rtx_activate_cmd])) ||
	__rtx_activate_cmd() {
		_arguments -s -S \
			'::shell_type:(bash fish nu xonsh zsh)' \
			'--status[Show "rtx\: <PLUGIN>@<VERSION>" message when changing directories]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_alias_cmd])) ||
	__rtx_alias_cmd() {
		_arguments -s -S \
			'(-p --plugin)'{-p,--plugin}'=[filter aliases by plugin]:plugin:__rtx_plugins' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_alias_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			get) __rtx_alias_get_cmd && ret=0 ;;
			list | ls) __rtx_alias_ls_cmd && ret=0 ;;
			add | create | set) __rtx_alias_set_cmd && ret=0 ;;
			del | delete | remove | rm | unset) __rtx_alias_unset_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_alias_get_cmd])) ||
	__rtx_alias_get_cmd() {
		_arguments -s -S \
			':plugin:__rtx_plugins' \
			':alias:__rtx_aliases' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_alias_ls_cmd])) ||
	__rtx_alias_ls_cmd() {
		_arguments -s -S \
			'::plugin:__rtx_plugins' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_alias_set_cmd])) ||
	__rtx_alias_set_cmd() {
		_arguments -s -S \
			':plugin:__rtx_plugins' \
			':alias:__rtx_aliases' \
			':value:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_alias_unset_cmd])) ||
	__rtx_alias_unset_cmd() {
		_arguments -s -S \
			':plugin:__rtx_plugins' \
			':alias:__rtx_aliases' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_asdf_cmd])) ||
	__rtx_asdf_cmd() {
		_arguments -s -S \
			'*::args:_cmdambivalent' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_bin_paths_cmd])) ||
	__rtx_bin_paths_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_cache_cmd])) ||
	__rtx_cache_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_cache_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			c | clean | clear) __rtx_cache_clear_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_cache_clear_cmd])) ||
	__rtx_cache_clear_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_completion_cmd])) ||
	__rtx_completion_cmd() {
		_arguments -s -S \
			'::shell:(bash fish zsh)' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_current_cmd])) ||
	__rtx_current_cmd() {
		_arguments -s -S \
			'::plugin:__rtx_plugins' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_deactivate_cmd])) ||
	__rtx_deactivate_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_direnv_cmd])) ||
	__rtx_direnv_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_direnv_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			activate) __rtx_direnv_activate_cmd && ret=0 ;;
			envrc) __rtx_direnv_envrc_cmd && ret=0 ;;
			exec) __rtx_direnv_exec_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_direnv_activate_cmd])) ||
	__rtx_direnv_activate_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_direnv_envrc_cmd])) ||
	__rtx_direnv_envrc_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_direnv_exec_cmd])) ||
	__rtx_direnv_exec_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_doctor_cmd])) ||
	__rtx_doctor_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_env_cmd])) ||
	__rtx_env_cmd() {
		_arguments -s -S \
			'(-s --shell)'{-s,--shell}'=[Shell type to generate environment variables for]:shell:(bash fish nu xonsh zsh)' \
			'*::tool:__rtx_tool_versions' \
			'(-J --json)'{-J,--json}'[Output in JSON format]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_env_vars_cmd])) ||
	__rtx_env_vars_cmd() {
		_arguments -s -S \
			'--file=[The TOML file to update]:file:_files' \
			'*--remove=[Remove the environment variable from config file]:remove:' \
			'*::env_vars:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_exec_cmd])) ||
	__rtx_exec_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-c --command)'{-c,--command}'=[Command string to execute]:c:_cmdstring' \
			'(-C --cd)'{-C,--cd}'=[Change to this directory before executing the command]:cd:_directories' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_global_cmd])) ||
	__rtx_global_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'--pin[Save exact version to \`~/.tool-versions\`]' \
			'--fuzzy[Save fuzzy version to \`~/.tool-versions\`]' \
			'*--remove=[Remove the plugin(s) from ~/.tool-versions]:remove:' \
			'--path[Get the path of the global config file]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_hook_env_cmd])) ||
	__rtx_hook_env_cmd() {
		_arguments -s -S \
			'(-s --shell)'{-s,--shell}'=[Shell type to generate script for]:shell:(bash fish nu xonsh zsh)' \
			'--status[Show "rtx\: <PLUGIN>@<VERSION>" message when changing directories]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_implode_cmd])) ||
	__rtx_implode_cmd() {
		_arguments -s -S \
			'--config[Also remove config directory]' \
			'(-n --dry-run)'{-n,--dry-run}'[List directories that would be removed without actually removing them]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_install_cmd])) ||
	__rtx_install_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-f --force)'{-f,--force}'[Force reinstall even if already installed]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_latest_cmd])) ||
	__rtx_latest_cmd() {
		_arguments -s -S \
			':tool:__rtx_tool_versions' \
			'(-i --installed)'{-i,--installed}'[Show latest installed instead of available version]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_link_cmd])) ||
	__rtx_link_cmd() {
		_arguments -s -S \
			':tool:__rtx_tool_versions' \
			':path:_directories' \
			'(-f --force)'{-f,--force}'[Overwrite an existing tool version if it exists]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_local_cmd])) ||
	__rtx_local_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-p --parent)'{-p,--parent}'[Recurse up to find a .tool-versions file rather than using the current directory only]' \
			'--pin[Save exact version to \`.tool-versions\`]' \
			'--fuzzy[Save fuzzy version to \`.tool-versions\` e.g.\: \`rtx local --fuzzy node@20\` will save \`node 20\` to .tool-versions This is the default behavior unless RTX_ASDF_COMPAT=1]' \
			'*--remove=[Remove the plugin(s) from .tool-versions]:remove:' \
			'--path[Get the path of the config file]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_ls_cmd])) ||
	__rtx_ls_cmd() {
		_arguments -s -S \
			'::plugin:__rtx_plugins' \
			'(-c --current)'{-c,--current}'[Only show tool versions currently specified in a .tool-versions/.rtx.toml]' \
			'(-g --global)'{-g,--global}'[Only show tool versions currently specified in a the global .tool-versions/.rtx.toml]' \
			'(-i --installed)'{-i,--installed}'[Only show tool versions that are installed Hides missing ones defined in .tool-versions/.rtx.toml but not yet installed]' \
			'(-J --json)'{-J,--json}'[Output in json format]' \
			'(-m --missing)'{-m,--missing}'[Display missing tool versions]' \
			'--prefix=[Display versions matching this prefix]:prefix:__rtx_prefixes' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_ls_remote_cmd])) ||
	__rtx_ls_remote_cmd() {
		_arguments -s -S \
			'::plugin:__rtx_plugins' \
			'--all[Show all installed plugins and versions]' \
			'::prefix:__rtx_prefixes' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_outdated_cmd])) ||
	__rtx_outdated_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_cmd])) ||
	__rtx_plugins_cmd() {
		_arguments -s -S \
			'(-c --core)'{-c,--core}'[The built-in plugins only]' \
			'--user[List installed plugins]' \
			'(-u --urls)'{-u,--urls}'[show the git url for each plugin]' \
			'--refs[show the git refs for each plugin]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_plugins_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			a | add | i | install) __rtx_plugins_install_cmd && ret=0 ;;
			l | link) __rtx_plugins_link_cmd && ret=0 ;;
			list | ls) __rtx_plugins_ls_cmd && ret=0 ;;
			list-all | list-remote | ls-remote) __rtx_plugins_ls_remote_cmd && ret=0 ;;
			remove | rm | uninstall) __rtx_plugins_uninstall_cmd && ret=0 ;;
			upgrade | update) __rtx_plugins_update_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_plugins_install_cmd])) ||
	__rtx_plugins_install_cmd() {
		_arguments -s -S \
			':new_plugin:__rtx_all_plugins' \
			'::git_url:_urls' \
			'(-f --force)'{-f,--force}'[Reinstall even if plugin exists]' \
			'(-a --all)'{-a,--all}'[Install all missing plugins]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_link_cmd])) ||
	__rtx_plugins_link_cmd() {
		_arguments -s -S \
			':name:' \
			'::path:_directories' \
			'(-f --force)'{-f,--force}'[Overwrite existing plugin]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_ls_cmd])) ||
	__rtx_plugins_ls_cmd() {
		_arguments -s -S \
			'(-c --core)'{-c,--core}'[The built-in plugins only]' \
			'--user[List installed plugins]' \
			'(-u --urls)'{-u,--urls}'[Show the git url for each plugin]' \
			'--refs[Show the git refs for each plugin]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_ls_remote_cmd])) ||
	__rtx_plugins_ls_remote_cmd() {
		_arguments -s -S \
			'(-u --urls)'{-u,--urls}'[Show the git url for each plugin e.g.\: https\://github.com/rtx-plugins/rtx-nodejs.git]' \
			'--only-names[Only show the name of each plugin by default it will show a "*" next to installed plugins]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_uninstall_cmd])) ||
	__rtx_plugins_uninstall_cmd() {
		_arguments -s -S \
			'*::plugin:__rtx_plugins' \
			'(-p --purge)'{-p,--purge}'[Also remove the plugin'\''s installs, downloads, and cache]' \
			'(-a --all)'{-a,--all}'[Remove all plugins]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_plugins_update_cmd])) ||
	__rtx_plugins_update_cmd() {
		_arguments -s -S \
			'*::plugin:__rtx_plugins' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_prune_cmd])) ||
	__rtx_prune_cmd() {
		_arguments -s -S \
			'*::plugin:__rtx_plugins' \
			'(-n --dry-run)'{-n,--dry-run}'[Do not actually delete anything]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_reshim_cmd])) ||
	__rtx_reshim_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_self_update_cmd])) ||
	__rtx_self_update_cmd() {
		_arguments -s -S \
			'(-f --force)'{-f,--force}'[Update even if already up to date]' \
			'--no-plugins[Disable auto-updating plugins]' \
			'(-y --yes)'{-y,--yes}'[Skip confirmation prompt]' \
			'::version:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]'
	}
(($ + functions[__rtx_settings_cmd])) ||
	__rtx_settings_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_settings_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			get) __rtx_settings_get_cmd && ret=0 ;;
			list | ls) __rtx_settings_ls_cmd && ret=0 ;;
			add | create | set) __rtx_settings_set_cmd && ret=0 ;;
			del | delete | remove | rm | unset) __rtx_settings_unset_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_settings_get_cmd])) ||
	__rtx_settings_get_cmd() {
		_arguments -s -S \
			':key:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_settings_ls_cmd])) ||
	__rtx_settings_ls_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_settings_set_cmd])) ||
	__rtx_settings_set_cmd() {
		_arguments -s -S \
			':key:' \
			':value:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_settings_unset_cmd])) ||
	__rtx_settings_unset_cmd() {
		_arguments -s -S \
			':key:' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_shell_cmd])) ||
	__rtx_shell_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-u --unset)'{-u,--unset}'[Removes a previously set version]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_sync_cmd])) ||
	__rtx_sync_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \
			'1: :__rtx_sync_cmds' \
			'*::arg:->args' && ret=0

		case "$state" in
		args)
			curcontext="${curcontext%:*:*}:rtx-cmd-$words[1]:"
			case $words[1] in
			node) __rtx_sync_node_cmd && ret=0 ;;
			python) __rtx_sync_python_cmd && ret=0 ;;
			esac
			;;
		esac

		return ret
	}
(($ + functions[__rtx_sync_node_cmd])) ||
	__rtx_sync_node_cmd() {
		_arguments -s -S \
			'--brew[Get tool versions from Homebrew]' \
			'--nvm[Get tool versions from nvm]' \
			'--nodenv[Get tool versions from nodenv]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_sync_python_cmd])) ||
	__rtx_sync_python_cmd() {
		_arguments -s -S \
			'--pyenv[Get tool versions from pyenv]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_trust_cmd])) ||
	__rtx_trust_cmd() {
		_arguments -s -S \
			'::config_file:_files' \
			'--untrust[No longer trust this config]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_uninstall_cmd])) ||
	__rtx_uninstall_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-a --all)'{-a,--all}'[Delete all installed versions]' \
			'(-n --dry-run)'{-n,--dry-run}'[Do not actually delete anything]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_upgrade_cmd])) ||
	__rtx_upgrade_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'(-n --dry-run)'{-n,--dry-run}'[Just print what would be done, don'\''t actually do it]' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_use_cmd])) ||
	__rtx_use_cmd() {
		_arguments -s -S \
			'*::tool:__rtx_tool_versions' \
			'--pin[Save exact version to config file]' \
			'--fuzzy[Save fuzzy version to config file]' \
			'*--remove=[Remove the tool(s) from config file]:remove:' \
			'(-g --global)'{-g,--global}'[Use the global config file (~/.config/rtx/config.toml) instead of the local one]' \
			'(-e --env)'{-e,--env}'=[\[experimental\] Modify an environment-specific config file like .rtx.<env>.toml]:env:' \
			'(-p --path)'{-p,--path}'=[Specify a path to a config file or directory If a directory is specified, it will look for .rtx.toml (default) or .tool-versions]:path:_files' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_version_cmd])) ||
	__rtx_version_cmd() {
		_arguments -s -S \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_where_cmd])) ||
	__rtx_where_cmd() {
		_arguments -s -S \
			':tool:__rtx_tool_versions' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_which_cmd])) ||
	__rtx_which_cmd() {
		_arguments -s -S \
			':bin_name:' \
			'--plugin[Show the plugin name instead of the path]' \
			'--version[Show the version instead of the path]' \
			'(-t --tool)'{-t,--tool}'=[Use a specific tool@version]:tool:__rtx_tool_versions' \
			'(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:jobs:' \
			'--log-level=[Set the log output verbosity]:log-level:(error warn info debug trace)' \
			'(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \
			'*'{-v,--verbose}'[Show installation output]' \
			'(-y --yes)'{-y,--yes}'[Answer yes to all prompts]'
	}
(($ + functions[__rtx_cmds])) ||
	__rtx_cmds() {
		local commands
		commands=(
			'activate:Initializes rtx in the current shell'
			{a,alias}':Manage aliases'
			'bin-paths:List all the active runtime bin paths'
			'cache:Manage the rtx cache'
			'completion:Generate shell completions'
			'current:Shows current active and installed runtime versions'
			'deactivate:Disable rtx for current shell session'
			'direnv:Output direnv function to use rtx inside direnv'
			'doctor:Check rtx installation for possible problems.'
			{e,env}':Exports env vars to activate rtx a single time'
			'env-vars:Manage environment variables'
			{x,exec}':Execute a command with tool(s) set'
			'implode:Removes rtx CLI and all related data'
			{i,install}':Install a tool version'
			'latest:Gets the latest available version for a plugin'
			'link:Symlinks a tool version into rtx'
			{list,ls}':List installed and/or currently selected tool versions'
			'ls-remote:List runtime versions available for install'
			'outdated:Shows outdated tool versions'
			{p,plugins}':Manage plugins'
			'prune:Delete unused versions of tools'
			'reshim:rebuilds the shim farm'
			'self-update:Updates rtx itself'
			'settings:Manage settings'
			'shell:Sets a tool version for the current shell session'
			'sync:Add tool versions from external tools to rtx'
			'trust:Marks a config file as trusted'
			'uninstall:Removes runtime versions'
			'upgrade:Upgrades outdated tool versions'
			{u,use}':Change the active version of a tool locally or globally.'
			'version:Show rtx version'
			'where:Display the installation path for a runtime'
			'which:Shows the path that a bin name points to'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_alias_cmds])) ||
	__rtx_alias_cmds() {
		local commands
		commands=(
			'get:Show an alias for a plugin'
			{list,ls}':List aliases'
			{add,create,set}':Add/update an alias for a plugin'
			{del,delete,remove,rm,unset}':Clears an alias for a plugin'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_cache_cmds])) ||
	__rtx_cache_cmds() {
		local commands
		commands=(
			{c,clear}':Deletes all cache files in rtx'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_direnv_cmds])) ||
	__rtx_direnv_cmds() {
		local commands
		commands=(
			'activate:Output direnv function to use rtx inside direnv'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_plugins_cmds])) ||
	__rtx_plugins_cmds() {
		local commands
		commands=(
			{a,i,install}':Install a plugin'
			'link:Symlinks a plugin into rtx'
			{list,ls}':List installed plugins'
			{list-remote,ls-remote}':List all available remote plugins'
			'uninstall:Removes a plugin'
			'update:Updates a plugin to the latest version'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_settings_cmds])) ||
	__rtx_settings_cmds() {
		local commands
		commands=(
			'get:Show a current setting'
			{list,ls}':Show current settings'
			{add,create,set}':Add/update a setting'
			{del,delete,remove,rm,unset}':Clears a setting'
		)
		_describe -t commands 'command' commands "$@"
	}
(($ + functions[__rtx_sync_cmds])) ||
	__rtx_sync_cmds() {
		local commands
		commands=(
			'node:Symlinks all tool versions from an external tool into rtx'
			'python:Symlinks all tool versions from an external tool into rtx'
		)
		_describe -t commands 'command' commands "$@"
	}

(($ + functions[__rtx_tool_versions])) ||
	__rtx_tool_versions() {
		if compset -P '*@'; then
			local -a tool_versions
			tool_versions=($(rtx ls-remote ${words[CURRENT]}))
			_wanted tool_version expl 'version of tool' \
				compadd -a tool_versions
		else
			local -a plugins
			plugins=($(rtx plugins --core --user))
			_wanted plugin expl 'plugin name' \
				compadd -S '@' -a plugins
		fi
	}
(($ + functions[__rtx_plugins])) ||
	__rtx_plugins() {
		local -a plugins
		plugins=($(rtx plugins --core --user))
		_describe -t plugins 'plugin' plugins "$@"
	}
(($ + functions[__rtx_all_plugins])) ||
	__rtx_all_plugins() {
		local -a all_plugins
		all_plugins=($(rtx plugins --all))
		_describe -t all_plugins 'all_plugins' all_plugins "$@"
	}
(($ + functions[__rtx_aliases])) ||
	__rtx_aliases() {
		local -a aliases
		aliases=($(rtx aliases ls ${words[CURRENT - 1]} | awk '{print $2}'))
		_describe -t aliases 'alias' aliases "$@"
	}
(($ + functions[__rtx_prefixes])) ||
	__rtx_prefixes() {
		local -a prefixes
		prefixes=($(rtx ls-remote ${words[CURRENT - 1]}))
		_describe -t prefixes 'prefix' prefixes "$@"
	}

if [ "$funcstack[1]" = "_rtx" ]; then
	_rtx "$@"
else
	compdef _rtx rtx
fi

# vim: noet ci pi sts=0 sw=4 ts=4
