diff --git a/.github/workflows/rtx.yml b/.github/workflows/rtx.yml index 3fca4c2b0..0f22f02a1 100644 --- a/.github/workflows/rtx.yml +++ b/.github/workflows/rtx.yml @@ -57,7 +57,7 @@ jobs: save-if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - uses: taiki-e/install-action@cargo-llvm-cov - name: Install zsh/fish/direnv - run: sudo apt-get update; sudo apt-get install zsh fish direnv + run: sudo apt-get update; sudo apt-get install zsh fish direnv shfmt - run: npm i -g markdown-magic - name: Install just uses: taiki-e/install-action@just diff --git a/README.md b/README.md index e4d22a38e..ef9d75440 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ v20.0.0 - [Commands](#commands) - [`rtx activate [OPTIONS] [SHELL_TYPE]`](#rtx-activate-options-shell_type) - [`rtx alias get `](#rtx-alias-get-plugin-alias) - - [`rtx alias ls [OPTIONS]`](#rtx-alias-ls-options) + - [`rtx alias ls [PLUGIN]`](#rtx-alias-ls-plugin) - [`rtx alias set `](#rtx-alias-set-plugin-alias-value) - [`rtx alias unset `](#rtx-alias-unset-plugin-alias) - [`rtx bin-paths`](#rtx-bin-paths) @@ -148,16 +148,16 @@ v20.0.0 - [`rtx install [OPTIONS] [TOOL@VERSION]...`](#rtx-install-options-toolversion) - [`rtx latest [OPTIONS] `](#rtx-latest-options-toolversion) - [`rtx link [OPTIONS] `](#rtx-link-options-toolversion-path) - - [`rtx ls [OPTIONS]`](#rtx-ls-options) + - [`rtx ls [OPTIONS] [PLUGIN]`](#rtx-ls-options-plugin) - [`rtx ls-remote [PREFIX]`](#rtx-ls-remote-toolversion-prefix) - [`rtx outdated [TOOL@VERSION]...`](#rtx-outdated-toolversion) - - [`rtx plugins install [OPTIONS] [NAME] [GIT_URL]`](#rtx-plugins-install-options-name-git_url) + - [`rtx plugins install [OPTIONS] [NEW_PLUGIN] [GIT_URL]`](#rtx-plugins-install-options-new_plugin-git_url) - [`rtx plugins link [OPTIONS] [PATH]`](#rtx-plugins-link-options-name-path) - [`rtx plugins ls [OPTIONS]`](#rtx-plugins-ls-options) - [`rtx plugins ls-remote [OPTIONS]`](#rtx-plugins-ls-remote-options) - - [`rtx plugins uninstall [OPTIONS] ...`](#rtx-plugins-uninstall-options-plugin) + - [`rtx plugins uninstall [OPTIONS] [PLUGIN]...`](#rtx-plugins-uninstall-options-plugin) - [`rtx plugins update [PLUGIN]...`](#rtx-plugins-update-plugin) - - [`rtx prune [OPTIONS] [PLUGINS]...`](#rtx-prune-options-plugins) + - [`rtx prune [OPTIONS] [PLUGIN]...`](#rtx-prune-options-plugin) - [`rtx reshim`](#rtx-reshim) - [`rtx self-update [OPTIONS] [VERSION]`](#rtx-self-update-options-version) - [`rtx settings get `](#rtx-settings-get-key) @@ -1670,7 +1670,7 @@ Examples: 20.0.0 ``` -### `rtx alias ls [OPTIONS]` +### `rtx alias ls [PLUGIN]` ``` List aliases @@ -1682,10 +1682,10 @@ For user config, aliases are defined like the following in `~/.config/rtx/config [alias.node] lts = "20.0.0" -Usage: alias ls [OPTIONS] +Usage: alias ls [PLUGIN] -Options: - -p, --plugin +Arguments: + [PLUGIN] Show aliases for Examples: @@ -1868,11 +1868,9 @@ Options: [possible values: bash, fish, nu, xonsh, zsh] - --json + -J, --json Output in JSON format - [short aliases: J] - Examples: $ eval "$(rtx env -s bash)" $ eval "$(rtx env -s zsh)" @@ -1933,11 +1931,9 @@ Options: -c, --command Command string to execute - --cd + -C, --cd Change to this directory before executing the command - [short aliases: C] - Examples: $ rtx exec node@20 -- node ./app.js # launch app.js using node-20.x $ rtx x node@20 -- node ./app.js # shorter alias @@ -1962,7 +1958,7 @@ Options: --config Also remove config directory - --dry-run + -n, --dry-run List directories that would be removed without actually removing them ``` @@ -2054,17 +2050,18 @@ Examples: $ rtx use node@brew ``` -### `rtx ls [OPTIONS]` +### `rtx ls [OPTIONS] [PLUGIN]` ``` List installed and/or currently selected tool versions -Usage: ls [OPTIONS] +Usage: ls [OPTIONS] [PLUGIN] -Options: - -p, --plugin +Arguments: + [PLUGIN] Only show tool versions from [PLUGIN] +Options: -c, --current Only show tool versions currently specified in a .tool-versions/.rtx.toml @@ -2074,11 +2071,9 @@ Options: -i, --installed Only show tool versions that are installed Hides missing ones defined in .tool-versions/.rtx.toml but not yet installed - --json + -J, --json Output in json format - [short aliases: J] - -m, --missing Display missing tool versions @@ -2167,7 +2162,7 @@ Examples: node 20 20.0.0 20.1.0 ``` -### `rtx plugins install [OPTIONS] [NAME] [GIT_URL]` +### `rtx plugins install [OPTIONS] [NEW_PLUGIN] [GIT_URL]` ``` Install a plugin @@ -2177,10 +2172,10 @@ e.g.: `rtx install node@20` will autoinstall the node plugin This behavior can be modified in ~/.config/rtx/config.toml -Usage: plugins install [OPTIONS] [NAME] [GIT_URL] +Usage: plugins install [OPTIONS] [NEW_PLUGIN] [GIT_URL] Arguments: - [NAME] + [NEW_PLUGIN] The name of the plugin to install e.g.: node, ruby Can specify multiple plugins: `rtx plugins install node ruby python` @@ -2259,6 +2254,12 @@ Options: The built-in plugins only Normally these are not shown + --user + List installed plugins + + This is the default behavior but can be used with --core + to show core and user plugins + -u, --urls Show the git url for each plugin e.g.: https://github.com/asdf-vm/asdf-node.git @@ -2298,21 +2299,24 @@ Options: Only show the name of each plugin by default it will show a "*" next to installed plugins ``` -### `rtx plugins uninstall [OPTIONS] ...` +### `rtx plugins uninstall [OPTIONS] [PLUGIN]...` ``` Removes a plugin -Usage: plugins uninstall [OPTIONS] ... +Usage: plugins uninstall [OPTIONS] [PLUGIN]... Arguments: - ... + [PLUGIN]... Plugin(s) to remove Options: -p, --purge Also remove the plugin's installs, downloads, and cache + -a, --all + Remove all plugins + Examples: $ rtx uninstall node ``` @@ -2336,7 +2340,7 @@ Examples: $ rtx plugins update node#beta # specify a ref ``` -### `rtx prune [OPTIONS] [PLUGINS]...` +### `rtx prune [OPTIONS] [PLUGIN]...` ``` Delete unused versions of tools @@ -2346,14 +2350,14 @@ Versions which are no longer the latest specified in any of those configs are de Versions installed only with environment variables (`RTX__VERSION`) will be deleted, as will versions only referenced on the command line (`rtx exec @`). -Usage: prune [OPTIONS] [PLUGINS]... +Usage: prune [OPTIONS] [PLUGIN]... Arguments: - [PLUGINS]... + [PLUGIN]... Prune only versions from these plugins Options: - --dry-run + -n, --dry-run Do not actually delete anything Examples: diff --git a/completions/_rtx b/completions/_rtx index 1565165d1..5540180a5 100644 --- a/completions/_rtx +++ b/completions/_rtx @@ -5,12 +5,12 @@ _rtx() { local ret=1 _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -42,9 +42,6 @@ _rtx() { (outdated) __rtx_outdated_cmd && ret=0 ;; (p|plugin|plugin-list|plugins) __rtx_plugins_cmd && ret=0 ;; (prune) __rtx_prune_cmd && ret=0 ;; - (render-completion) __rtx_render_completion_cmd && ret=0 ;; - (render-help) __rtx_render_help_cmd && ret=0 ;; - (render-mangen) __rtx_render_mangen_cmd && ret=0 ;; (reshim) __rtx_reshim_cmd && ret=0 ;; (self-update) __rtx_self_update_cmd && ret=0 ;; (settings) __rtx_settings_cmd && ret=0 ;; @@ -63,25 +60,27 @@ _rtx() { return ret } +(( $+functions[__rtx_activate_cmd] )) || __rtx_activate_cmd() { _arguments -s -S \ - '*::shell_type:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--status=[Show "rtx: @" message when changing directories]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '::shell_type:(bash fish nu xonsh zsh)' \ + '--status[Show "rtx\: @" 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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_alias_cmd] )) || __rtx_alias_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-p --plugin)'{-p,--plugin}'=[filter aliases by plugin]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_alias_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -98,71 +97,78 @@ __rtx_alias_cmd() { return ret } +(( $+functions[__rtx_alias_get_cmd] )) || __rtx_alias_get_cmd() { _arguments -s -S \ - '*::alias:' \ - '*::plugin:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-p --plugin)'{-p,--plugin}'=[Show aliases for ]:: :' \ + '::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '*::alias:' \ - '*::plugin:' \ - '*::value:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '*::alias:' \ - '*::plugin:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '*::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_cache_cmd] )) || __rtx_cache_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_cache_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -176,48 +182,53 @@ __rtx_cache_cmd() { return ret } +(( $+functions[__rtx_cache_clear_cmd] )) || __rtx_cache_clear_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_deactivate_cmd] )) || __rtx_deactivate_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_direnv_cmd] )) || __rtx_direnv_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_direnv_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -233,195 +244,213 @@ __rtx_direnv_cmd() { return ret } +(( $+functions[__rtx_direnv_activate_cmd] )) || __rtx_direnv_activate_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_doctor_cmd] )) || __rtx_doctor_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--json=[Output in JSON format]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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.]' \ - '(-s --shell)'{-s,--shell}'=[Shell type to generate environment variables for]: :(bash fish nu xonsh zsh)' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--file=[The TOML file to update]:: :' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--remove=[Remove the environment variable from config file]:: :' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_exec_cmd] )) || __rtx_exec_cmd() { _arguments -s -S \ - '*::command:' \ '*::tool:__rtx_tool_versions' \ - '--cd=[Change to this directory before executing the command]:: :' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-c --command)'{-c,--command}'=[Command string to execute]:: :' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--fuzzy=[Save fuzzy version to `~/.tool-versions`]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--path=[Get the path of the global config file]' \ - '--pin=[Save exact version to `~/.tool-versions`]' \ - '--remove=[Remove the plugin(s) from ~/.tool-versions]:: :' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--status=[Show "rtx: @" message when changing directories]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-s --shell)'{-s,--shell}'=[Shell type to generate script for]:shell:(bash fish nu xonsh zsh)' \ + '--status[Show "rtx\: @" 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.]' \ - '(-s --shell)'{-s,--shell}'=[Shell type to generate script for]: :(bash fish nu xonsh zsh)' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '*'{-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]' \ - '--dry-run=[List directories that would be removed without actually removing them]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ '(-f --force)'{-f,--force}'[Force reinstall even if already installed]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '*'{-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.]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_latest_cmd] )) || __rtx_latest_cmd() { _arguments -s -S \ - '1::tool:__rtx_tool_versions' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ + ':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]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_link_cmd] )) || __rtx_link_cmd() { _arguments -s -S \ - '1: :_directories' \ - '1::tool:__rtx_tool_versions' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ + ':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]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--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]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--path=[Get the path of the config file]' \ - '--pin=[Save exact version to `.tool-versions`]' \ - '--remove=[Remove the plugin(s) from .tool-versions]:: :' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_ls_cmd] )) || __rtx_ls_cmd() { _arguments -s -S \ - '--json=[Output in json format]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--prefix=[Display versions matching this prefix]:: :' \ + '::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 --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-J --json)'{-J,--json}'[Output in json format]' \ '(-m --missing)'{-m,--missing}'[Display missing tool versions]' \ - '(-p --plugin)'{-p,--plugin}'=[Only show tool versions from [PLUGIN]]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '*::prefix:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':plugin:__rtx_plugins' \ + '::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_plugins_cmd] )) || __rtx_plugins_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--refs=[show the git refs for each plugin]' \ '(-c --core)'{-c,--core}'[The built-in plugins only]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ + '--user[List installed plugins]' \ '(-u --urls)'{-u,--urls}'[show the git url for each plugin]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '--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_cmds' \ + '1: :__rtx_plugins_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -440,131 +469,118 @@ __rtx_plugins_cmd() { return ret } +(( $+functions[__rtx_plugins_install_cmd] )) || __rtx_plugins_install_cmd() { _arguments -s -S \ - '1: :_urls' \ - '*::name:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-a --all)'{-a,--all}'[Install all missing plugins]' \ + ':new_plugin:__rtx_all_plugins' \ + '::git_url:_urls' \ '(-f --force)'{-f,--force}'[Reinstall even if plugin exists]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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.]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_plugins_link_cmd] )) || __rtx_plugins_link_cmd() { _arguments -s -S \ - '*::name:' \ - '1: :_directories' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ + ':name:' \ + '::path:_directories' \ '(-f --force)'{-f,--force}'[Overwrite existing plugin]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--refs=[Show the git refs for each plugin]' \ '(-c --core)'{-c,--core}'[The built-in plugins only]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ + '--user[List installed plugins]' \ '(-u --urls)'{-u,--urls}'[Show the git url for each plugin]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '--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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--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]:: :' \ + '(-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.]' \ - '(-u --urls)'{-u,--urls}'[Show the git url for each plugin e.g.: https://github.com/rtx-plugins/rtx-nodejs.git]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '*::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '*::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_prune_cmd] )) || __rtx_prune_cmd() { _arguments -s -S \ - '*::plugins:' \ - '--dry-run=[Do not actually delete anything]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ - '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' -} -__rtx_render_completion_cmd() { - _arguments -s -S \ - '*::shell:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ - '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' -} -__rtx_render_help_cmd() { - _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ - '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' -} -__rtx_render_mangen_cmd() { - _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '*::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_reshim_cmd] )) || __rtx_reshim_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '*::version:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--no-plugins=[Disable auto-updating plugins]' \ '(-f --force)'{-f,--force}'[Update even if already up to date]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ - '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' + '*'{-v,--verbose}'[Show installation output]' } +(( $+functions[__rtx_settings_cmd] )) || __rtx_settings_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_settings_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -581,60 +597,66 @@ __rtx_settings_cmd() { return ret } +(( $+functions[__rtx_settings_get_cmd] )) || __rtx_settings_get_cmd() { _arguments -s -S \ - '*::key:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ '(-u --unset)'{-u,--unset}'[Removes a previously set version]' \ - '(-v --verbose)'{-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.]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_sync_cmd] )) || __rtx_sync_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' \ - '1: :_rtx_cmds' \ + '1: :__rtx_sync_cmds' \ '*::arg:->args' && ret=0 case "$state" in @@ -649,102 +671,111 @@ __rtx_sync_cmd() { return ret } +(( $+functions[__rtx_sync_node_cmd] )) || __rtx_sync_node_cmd() { _arguments -s -S \ - '--brew=[Get tool versions from Homebrew]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--nodenv=[Get tool versions from nodenv]' \ - '--nvm=[Get tool versions from nvm]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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 \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--pyenv=[Get tool versions from pyenv]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '--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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_trust_cmd] )) || __rtx_trust_cmd() { _arguments -s -S \ - '1: :_files' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--untrust=[No longer trust this config]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '::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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ '(-a --all)'{-a,--all}'[Delete all installed versions]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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' \ - '--fuzzy=[Save fuzzy version to config file]' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--pin=[Save exact version to config file]' \ - '--remove=[Remove the tool(s) from config file]:: :' \ - '(-e --env)'{-e,--env}'=[[experimental] Modify an environment-specific config file like .rtx..toml]:: :' \ + '--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]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - '(-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]:: :' \ + '(-e --env)'{-e,--env}'=[\[experimental\] Modify an environment-specific config file like .rtx..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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_version_cmd] )) || __rtx_version_cmd() { _arguments -s -S \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + '(-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)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } +(( $+functions[__rtx_where_cmd] )) || __rtx_where_cmd() { _arguments -s -S \ - '1::tool:__rtx_tool_versions' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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)'{-v,--verbose}'[Show installation output]' \ + '*'{-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:' \ - '--log-level=[Set the log output verbosity]: :(error warn info debug trace)' \ - '--plugin=[Show the plugin name instead of the path]' \ - '--version=[Show the version instead of the path]' \ - '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ + ':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.]' \ - '(-t --tool)'{-t,--tool}'=[Use a specific tool@version]:: :' \ - '(-v --verbose)'{-v,--verbose}'[Show installation output]' \ + '*'{-v,--verbose}'[Show installation output]' \ '(-y --yes)'{-y,--yes}'[Answer yes to all prompts]' } -(( $+functions[_rtx_cmds] )) || -_rtx_cmds() { +(( $+functions[__rtx_cmds] )) || +__rtx_cmds() { local commands; commands=( 'activate:Initializes rtx in the current shell' {a,alias}':Manage aliases' @@ -782,20 +813,99 @@ _rtx_cmds() { ) _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)) + 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 "$@" +} -_rtx "$@" +if [ "$funcstack[1]" = "_rtx" ]; then + _rtx "$@" +else + compdef _rtx rtx +fi # Local Variables: # mode: Shell-Script diff --git a/completions/rtx.bash b/completions/rtx.bash index 991535e57..7227365de 100644 --- a/completions/rtx.bash +++ b/completions/rtx.bash @@ -763,20 +763,12 @@ _rtx() { return 0 ;; rtx__alias__ls) - opts="-p -j -r -v -y -h --plugin --jobs --debug --log-level --trace --raw --verbose --yes --help" + opts="-j -r -v -y -h --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGIN]" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in - --plugin) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - -p) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; --jobs) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -1281,7 +1273,7 @@ _rtx() { return 0 ;; rtx__env) - opts="-s -j -r -v -y -h --shell --json --jobs --debug --log-level --trace --raw --verbose --yes --help [TOOL@VERSION]..." + opts="-s -J -j -r -v -y -h --shell --json --jobs --debug --log-level --trace --raw --verbose --yes --help [TOOL@VERSION]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1349,7 +1341,7 @@ _rtx() { return 0 ;; rtx__exec) - opts="-c -j -r -v -y -h --command --cd --jobs --debug --log-level --trace --raw --verbose --yes --help [TOOL@VERSION]... [COMMAND]..." + opts="-c -C -j -r -v -y -h --command --cd --jobs --debug --log-level --trace --raw --verbose --yes --help [TOOL@VERSION]... [COMMAND]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1367,6 +1359,10 @@ _rtx() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + -C) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --jobs) COMPREPLY=($(compgen -f "${cur}")) return 0 @@ -2319,7 +2315,7 @@ _rtx() { return 0 ;; rtx__implode) - opts="-j -r -v -y -h --config --dry-run --jobs --debug --log-level --trace --raw --verbose --yes --help" + opts="-n -j -r -v -y -h --config --dry-run --jobs --debug --log-level --trace --raw --verbose --yes --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2453,7 +2449,7 @@ _rtx() { return 0 ;; rtx__ls) - opts="-p -c -g -i -m -j -r -v -y -h --plugin --current --global --installed --parseable --json --missing --prefix --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGIN_ARG]" + opts="-p -c -g -i -J -m -j -r -v -y -h --plugin --current --global --installed --parseable --json --missing --prefix --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGIN]" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2543,7 +2539,7 @@ _rtx() { return 0 ;; rtx__plugins) - opts="-a -c -u -j -r -v -y -h --all --core --urls --refs --jobs --debug --log-level --trace --raw --verbose --yes --help install link ls ls-remote uninstall update help" + opts="-a -c -u -j -r -v -y -h --all --core --user --urls --refs --jobs --debug --log-level --trace --raw --verbose --yes --help install link ls ls-remote uninstall update help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2681,7 +2677,7 @@ _rtx() { return 0 ;; rtx__plugins__install) - opts="-f -a -v -j -r -y -h --force --all --verbose --jobs --debug --log-level --trace --raw --yes --help [NAME] [GIT_URL] [REST]..." + opts="-f -a -v -j -r -y -h --force --all --verbose --jobs --debug --log-level --trace --raw --yes --help [NEW_PLUGIN] [GIT_URL] [REST]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2733,7 +2729,7 @@ _rtx() { return 0 ;; rtx__plugins__ls) - opts="-a -c -u -j -r -v -y -h --all --core --urls --refs --jobs --debug --log-level --trace --raw --verbose --yes --help" + opts="-a -c -u -j -r -v -y -h --all --core --user --urls --refs --jobs --debug --log-level --trace --raw --verbose --yes --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2785,7 +2781,7 @@ _rtx() { return 0 ;; rtx__plugins__uninstall) - opts="-p -j -r -v -y -h --purge --jobs --debug --log-level --trace --raw --verbose --yes --help ..." + opts="-p -a -j -r -v -y -h --purge --all --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGIN]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2837,7 +2833,7 @@ _rtx() { return 0 ;; rtx__prune) - opts="-j -r -v -y -h --dry-run --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGINS]..." + opts="-n -j -r -v -y -h --dry-run --jobs --debug --log-level --trace --raw --verbose --yes --help [PLUGIN]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/completions/rtx.fish b/completions/rtx.fish index 2fad590b9..09c484423 100644 --- a/completions/rtx.fish +++ b/completions/rtx.fish @@ -91,7 +91,6 @@ Sets --jobs=1' complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from get" -s v -l verbose -d 'Show installation output' complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from get" -s y -l yes -d 'Answer yes to all prompts' complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from get" -s h -l help -d 'Print help (see more with \'--help\')' -complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from ls" -s p -l plugin -d 'Show aliases for ' -r complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from ls" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from alias; and __fish_seen_subcommand_from ls" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" @@ -270,7 +269,7 @@ complete -c rtx -n "__fish_seen_subcommand_from env" -s s -l shell -d 'Shell typ complete -c rtx -n "__fish_seen_subcommand_from env" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from env" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" -complete -c rtx -n "__fish_seen_subcommand_from env" -l json -d 'Output in JSON format' +complete -c rtx -n "__fish_seen_subcommand_from env" -s J -l json -d 'Output in JSON format' complete -c rtx -n "__fish_seen_subcommand_from env" -l debug -d 'Sets log level to debug' complete -c rtx -n "__fish_seen_subcommand_from env" -l trace -d 'Sets log level to trace' complete -c rtx -n "__fish_seen_subcommand_from env" -s r -l raw -d 'Directly pipe stdin/stdout/stderr to user. @@ -278,7 +277,7 @@ Sets --jobs=1' complete -c rtx -n "__fish_seen_subcommand_from env" -s v -l verbose -d 'Show installation output' complete -c rtx -n "__fish_seen_subcommand_from env" -s y -l yes -d 'Answer yes to all prompts' complete -c rtx -n "__fish_seen_subcommand_from env" -s h -l help -d 'Print help (see more with \'--help\')' -complete -c rtx -n "__fish_seen_subcommand_from env-vars" -l file -d 'The TOML file to update' -r +complete -c rtx -n "__fish_seen_subcommand_from env-vars" -l file -d 'The TOML file to update' -r -F complete -c rtx -n "__fish_seen_subcommand_from env-vars" -l remove -d 'Remove the environment variable from config file' -r complete -c rtx -n "__fish_seen_subcommand_from env-vars" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r @@ -291,7 +290,7 @@ complete -c rtx -n "__fish_seen_subcommand_from env-vars" -s v -l verbose -d 'Sh complete -c rtx -n "__fish_seen_subcommand_from env-vars" -s y -l yes -d 'Answer yes to all prompts' complete -c rtx -n "__fish_seen_subcommand_from env-vars" -s h -l help -d 'Print help (see more with \'--help\')' complete -c rtx -n "__fish_seen_subcommand_from exec" -s c -l command -d 'Command string to execute' -r -f -a "(__fish_complete_command)" -complete -c rtx -n "__fish_seen_subcommand_from exec" -l cd -d 'Change to this directory before executing the command' -r -f -a "(__fish_complete_directories)" +complete -c rtx -n "__fish_seen_subcommand_from exec" -s C -l cd -d 'Change to this directory before executing the command' -r -f -a "(__fish_complete_directories)" complete -c rtx -n "__fish_seen_subcommand_from exec" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from exec" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" @@ -335,7 +334,7 @@ complete -c rtx -n "__fish_seen_subcommand_from implode" -s j -l jobs -d 'Number [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from implode" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" complete -c rtx -n "__fish_seen_subcommand_from implode" -l config -d 'Also remove config directory' -complete -c rtx -n "__fish_seen_subcommand_from implode" -l dry-run -d 'List directories that would be removed without actually removing them' +complete -c rtx -n "__fish_seen_subcommand_from implode" -s n -l dry-run -d 'List directories that would be removed without actually removing them' complete -c rtx -n "__fish_seen_subcommand_from implode" -l debug -d 'Sets log level to debug' complete -c rtx -n "__fish_seen_subcommand_from implode" -l trace -d 'Sets log level to trace' complete -c rtx -n "__fish_seen_subcommand_from implode" -s r -l raw -d 'Directly pipe stdin/stdout/stderr to user. @@ -393,7 +392,7 @@ Sets --jobs=1' complete -c rtx -n "__fish_seen_subcommand_from local" -s v -l verbose -d 'Show installation output' complete -c rtx -n "__fish_seen_subcommand_from local" -s y -l yes -d 'Answer yes to all prompts' complete -c rtx -n "__fish_seen_subcommand_from local" -s h -l help -d 'Print help (see more with \'--help\')' -complete -c rtx -n "__fish_seen_subcommand_from ls" -s p -l plugin -d 'Only show tool versions from [PLUGIN]' -r +complete -c rtx -n "__fish_seen_subcommand_from ls" -s p -l plugin -r complete -c rtx -n "__fish_seen_subcommand_from ls" -l prefix -d 'Display versions matching this prefix' -r complete -c rtx -n "__fish_seen_subcommand_from ls" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r @@ -402,7 +401,7 @@ complete -c rtx -n "__fish_seen_subcommand_from ls" -s c -l current -d 'Only sho complete -c rtx -n "__fish_seen_subcommand_from ls" -s g -l global -d 'Only show tool versions currently specified in a the global .tool-versions/.rtx.toml' complete -c rtx -n "__fish_seen_subcommand_from ls" -s i -l installed -d 'Only show tool versions that are installed Hides missing ones defined in .tool-versions/.rtx.toml but not yet installed' complete -c rtx -n "__fish_seen_subcommand_from ls" -l parseable -d 'Output in an easily parseable format' -complete -c rtx -n "__fish_seen_subcommand_from ls" -l json -d 'Output in json format' +complete -c rtx -n "__fish_seen_subcommand_from ls" -s J -l json -d 'Output in json format' complete -c rtx -n "__fish_seen_subcommand_from ls" -s m -l missing -d 'Display missing tool versions' complete -c rtx -n "__fish_seen_subcommand_from ls" -l debug -d 'Sets log level to debug' complete -c rtx -n "__fish_seen_subcommand_from ls" -l trace -d 'Sets log level to trace' @@ -437,6 +436,7 @@ complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_sub complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -s a -l all -d 'list all available remote plugins' complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -s c -l core -d 'The built-in plugins only Normally these are not shown' +complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -l user -d 'List installed plugins' complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -s u -l urls -d 'show the git url for each plugin' complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -l refs -d 'show the git refs for each plugin' complete -c rtx -n "__fish_seen_subcommand_from plugins; and not __fish_seen_subcommand_from install; and not __fish_seen_subcommand_from link; and not __fish_seen_subcommand_from ls; and not __fish_seen_subcommand_from ls-remote; and not __fish_seen_subcommand_from uninstall; and not __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help" -l debug -d 'Sets log level to debug' @@ -485,6 +485,7 @@ complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcomm Same as `rtx plugins ls-remote`' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from ls" -s c -l core -d 'The built-in plugins only Normally these are not shown' +complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from ls" -l user -d 'List installed plugins' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from ls" -s u -l urls -d 'Show the git url for each plugin e.g.: https://github.com/asdf-vm/asdf-node.git' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from ls" -l refs -d 'Show the git refs for each plugin @@ -512,6 +513,7 @@ complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcomm [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -s p -l purge -d 'Also remove the plugin\'s installs, downloads, and cache' +complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -s a -l all -d 'Remove all plugins' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -l debug -d 'Sets log level to debug' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -l trace -d 'Sets log level to trace' complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcommand_from uninstall" -s r -l raw -d 'Directly pipe stdin/stdout/stderr to user. @@ -540,7 +542,7 @@ complete -c rtx -n "__fish_seen_subcommand_from plugins; and __fish_seen_subcomm complete -c rtx -n "__fish_seen_subcommand_from prune" -s j -l jobs -d 'Number of plugins and runtimes to install in parallel [default: 4]' -r complete -c rtx -n "__fish_seen_subcommand_from prune" -l log-level -d 'Set the log output verbosity' -r -f -a "{error '',warn '',info '',debug '',trace ''}" -complete -c rtx -n "__fish_seen_subcommand_from prune" -l dry-run -d 'Do not actually delete anything' +complete -c rtx -n "__fish_seen_subcommand_from prune" -s n -l dry-run -d 'Do not actually delete anything' complete -c rtx -n "__fish_seen_subcommand_from prune" -l debug -d 'Sets log level to debug' complete -c rtx -n "__fish_seen_subcommand_from prune" -l trace -d 'Sets log level to trace' complete -c rtx -n "__fish_seen_subcommand_from prune" -s r -l raw -d 'Directly pipe stdin/stdout/stderr to user. diff --git a/justfile b/justfile index 4fcd43713..ff82bd530 100644 --- a/justfile +++ b/justfile @@ -112,7 +112,7 @@ render-mangen: build NO_COLOR=1 rtx render-mangen # called by lefthook precommit hook -pre-commit: render-help render-completions render-mangen +pre-commit: render-help render-completions render-mangen lint git add README.md git add completions git add man diff --git a/lefthook.yml b/lefthook.yml index 52553ed23..da19c9b66 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -4,9 +4,6 @@ pre-commit: pre-commit: run: just -v pre-commit interactive: true - lint: - run: just -v lint - interactive: true skip_output: - meta - summary diff --git a/src/cli/alias/ls.rs b/src/cli/alias/ls.rs index d661a1415..88e0589f5 100644 --- a/src/cli/alias/ls.rs +++ b/src/cli/alias/ls.rs @@ -16,7 +16,7 @@ use crate::plugins::PluginName; #[clap(visible_alias = "list", after_long_help = AFTER_LONG_HELP, verbatim_doc_comment)] pub struct AliasLs { /// Show aliases for - #[clap(short, long)] + #[clap()] pub plugin: Option, } @@ -34,7 +34,11 @@ impl AliasLs { // hide the nvm-style aliases so only asdf-style ones display continue; } - rtxprintln!(out, "{:20} {:20} {}", plugin_name, from, to); + if self.plugin.is_some() { + rtxprintln!(out, "{:20} {}", from, to); + } else { + rtxprintln!(out, "{:20} {:20} {}", plugin_name, from, to); + } } } Ok(()) diff --git a/src/cli/asdf.rs b/src/cli/asdf.rs index 4a355228e..feb073e3b 100644 --- a/src/cli/asdf.rs +++ b/src/cli/asdf.rs @@ -1,3 +1,4 @@ +use clap::ValueHint::CommandWithArguments; use color_eyre::eyre::Result; use itertools::Itertools; @@ -11,7 +12,7 @@ use crate::toolset::ToolsetBuilder; #[clap(hide = true, verbatim_doc_comment)] pub struct Asdf { /// all arguments - #[clap(allow_hyphen_values = true)] + #[clap(allow_hyphen_values = true, value_hint = CommandWithArguments, trailing_var_arg = true)] args: Vec, } diff --git a/src/cli/env.rs b/src/cli/env.rs index 75a4f9227..1bb1279f2 100644 --- a/src/cli/env.rs +++ b/src/cli/env.rs @@ -22,7 +22,7 @@ pub struct Env { tool: Vec, /// Output in JSON format - #[clap(long, visible_short_alias = 'J', overrides_with = "shell")] + #[clap(long, short = 'J', overrides_with = "shell")] json: bool, } diff --git a/src/cli/env_vars.rs b/src/cli/env_vars.rs index faf36f052..8a216b6e5 100644 --- a/src/cli/env_vars.rs +++ b/src/cli/env_vars.rs @@ -20,7 +20,7 @@ pub struct EnvVars { /// The TOML file to update /// /// Defaults to RTX_DEFAULT_CONFIG_FILENAME environment variable, or ".rtx.toml". - #[clap(long, verbatim_doc_comment, required = false)] + #[clap(long, verbatim_doc_comment, required = false, value_hint = clap::ValueHint::FilePath)] file: Option, /// Remove the environment variable from config file diff --git a/src/cli/exec.rs b/src/cli/exec.rs index 4740a2bc4..ebefbb96e 100644 --- a/src/cli/exec.rs +++ b/src/cli/exec.rs @@ -40,7 +40,7 @@ pub struct Exec { pub c: Option, /// Change to this directory before executing the command - #[clap(visible_short_alias = 'C', value_hint = ValueHint::DirPath, long)] + #[clap(short = 'C', value_hint = ValueHint::DirPath, long)] pub cd: Option, } diff --git a/src/cli/implode.rs b/src/cli/implode.rs index 7e9e47506..a52af9d6b 100644 --- a/src/cli/implode.rs +++ b/src/cli/implode.rs @@ -19,7 +19,7 @@ pub struct Implode { config: bool, /// List directories that would be removed without actually removing them - #[clap(long, verbatim_doc_comment)] + #[clap(long, short = 'n', verbatim_doc_comment)] dry_run: bool, } diff --git a/src/cli/ls.rs b/src/cli/ls.rs index b2ff1f373..09f10bac9 100644 --- a/src/cli/ls.rs +++ b/src/cli/ls.rs @@ -23,11 +23,11 @@ use crate::toolset::{ToolSource, ToolVersion, ToolsetBuilder}; #[clap(visible_alias = "list", verbatim_doc_comment, after_long_help = AFTER_LONG_HELP)] pub struct Ls { /// Only show tool versions from [PLUGIN] - #[clap(long, short)] + #[clap(conflicts_with = "plugin_flag")] plugin: Option, - #[clap(hide = true)] - plugin_arg: Option, + #[clap(long = "plugin", short, hide = true)] + plugin_flag: Option, /// Only show tool versions currently specified in a .tool-versions/.rtx.toml #[clap(long, short)] @@ -43,11 +43,11 @@ pub struct Ls { installed: bool, /// Output in an easily parseable format - #[clap(long, hide = true, visible_short_alias = 'x', conflicts_with = "json")] + #[clap(long, hide = true, conflicts_with = "json")] parseable: bool, /// Output in json format - #[clap(long, visible_short_alias = 'J', overrides_with = "parseable")] + #[clap(long, short = 'J', overrides_with = "parseable")] json: bool, /// Display missing tool versions @@ -55,7 +55,7 @@ pub struct Ls { missing: bool, /// Display versions matching this prefix - #[clap(long)] + #[clap(long, requires = "plugin")] prefix: Option, } @@ -64,7 +64,7 @@ impl Ls { self.plugin = self .plugin .clone() - .or(self.plugin_arg.clone()) + .or(self.plugin_flag.clone()) .map(|p| PluginName::from(unalias_plugin(&p))); self.verify_plugin(&config)?; @@ -81,9 +81,6 @@ impl Ls { runtimes.retain(|(p, tv, _)| !p.is_version_installed(tv)); } if let Some(prefix) = &self.prefix { - if self.plugin.is_none() { - panic!("--prefix requires --plugin"); - } runtimes.retain(|(_, tv, _)| tv.version.starts_with(prefix)); } if self.json { @@ -418,7 +415,7 @@ mod tests { fn test_ls_parseable() { let _ = remove_all(dirs::INSTALLS.as_path()); assert_cli!("install"); - assert_cli_snapshot!("ls", "-x"); + assert_cli_snapshot!("ls", "--parseable"); assert_cli_snapshot!("ls", "--parseable", "tiny"); } diff --git a/src/cli/plugins/install.rs b/src/cli/plugins/install.rs index 81016244f..2c15c7af3 100644 --- a/src/cli/plugins/install.rs +++ b/src/cli/plugins/install.rs @@ -21,7 +21,7 @@ pub struct PluginsInstall { /// e.g.: node, ruby /// Can specify multiple plugins: `rtx plugins install node ruby python` #[clap(required_unless_present = "all", verbatim_doc_comment)] - name: Option, + new_plugin: Option, /// The git url of the plugin /// e.g.: https://github.com/asdf-vm/asdf-node.git @@ -35,7 +35,7 @@ pub struct PluginsInstall { /// Install all missing plugins /// This will only install plugins that have matching shorthands. /// i.e.: they don't need the full git repo url - #[clap(short, long, conflicts_with_all = ["name", "force"], verbatim_doc_comment)] + #[clap(short, long, conflicts_with_all = ["new_plugin", "force"], verbatim_doc_comment)] all: bool, /// Show installation output @@ -52,7 +52,7 @@ impl PluginsInstall { if self.all { return self.install_all_missing_plugins(config, mpr); } - let (name, git_url) = get_name_and_url(&self.name.clone().unwrap(), &self.git_url)?; + let (name, git_url) = get_name_and_url(&self.new_plugin.clone().unwrap(), &self.git_url)?; if git_url.is_some() { self.install_one(&mut config, name, git_url, &mpr)?; } else { diff --git a/src/cli/plugins/ls.rs b/src/cli/plugins/ls.rs index 836e74f1e..3f2791b86 100644 --- a/src/cli/plugins/ls.rs +++ b/src/cli/plugins/ls.rs @@ -21,9 +21,16 @@ pub struct PluginsLs { /// The built-in plugins only /// Normally these are not shown - #[clap(short, long, verbatim_doc_comment)] + #[clap(short, long, verbatim_doc_comment, conflicts_with = "all")] pub core: bool, + /// List installed plugins + /// + /// This is the default behavior but can be used with --core + /// to show core and user plugins + #[clap(long, verbatim_doc_comment, conflicts_with = "all")] + pub user: bool, + /// Show the git url for each plugin /// e.g.: https://github.com/asdf-vm/asdf-node.git #[clap(short, long, verbatim_doc_comment)] @@ -46,6 +53,7 @@ impl PluginsLs { let tool = Tool::new(plugin.clone(), Box::from(ep)); tools.insert(Arc::new(tool)); } + } else if self.user && self.core { } else if self.core { tools.retain(|p| matches!(p.plugin.get_type(), PluginType::Core)); } else { diff --git a/src/cli/plugins/mod.rs b/src/cli/plugins/mod.rs index 2ca6ec611..dde5e2f4d 100644 --- a/src/cli/plugins/mod.rs +++ b/src/cli/plugins/mod.rs @@ -25,9 +25,16 @@ pub struct Plugins { /// The built-in plugins only /// Normally these are not shown - #[clap(short, long, verbatim_doc_comment)] + #[clap(short, long, verbatim_doc_comment, conflicts_with = "all")] pub core: bool, + /// List installed plugins + /// + /// This is the default behavior but can be used with --core + /// to show core and user plugins + #[clap(long, verbatim_doc_comment, conflicts_with = "all")] + pub user: bool, + /// show the git url for each plugin /// /// e.g.: https://github.com/asdf-vm/asdf-node.git @@ -69,8 +76,9 @@ impl Plugins { let cmd = self.command.unwrap_or(Commands::Ls(ls::PluginsLs { all: self.all, core: self.core, - urls: self.urls, refs: self.refs, + urls: self.urls, + user: self.user, })); cmd.run(config, out) diff --git a/src/cli/plugins/uninstall.rs b/src/cli/plugins/uninstall.rs index c5740fb9a..9ea6f1bae 100644 --- a/src/cli/plugins/uninstall.rs +++ b/src/cli/plugins/uninstall.rs @@ -11,20 +11,29 @@ use crate::ui::multi_progress_report::MultiProgressReport; #[clap(verbatim_doc_comment, alias = "remove", alias = "rm", after_long_help = AFTER_LONG_HELP)] pub struct PluginsUninstall { /// Plugin(s) to remove - #[clap(required = true, verbatim_doc_comment)] - pub plugin: Vec, + #[clap(verbatim_doc_comment)] + plugin: Vec, /// Also remove the plugin's installs, downloads, and cache #[clap(long, short, verbatim_doc_comment)] - pub purge: bool, + purge: bool, + + /// Remove all plugins + #[clap(long, short, verbatim_doc_comment, conflicts_with = "plugin")] + all: bool, } impl PluginsUninstall { pub fn run(self, config: Config, _out: &mut Output) -> Result<()> { let mpr = MultiProgressReport::new(config.show_progress_bars()); - for plugin_name in &self.plugin { - let plugin_name = unalias_plugin(plugin_name); + let plugins = match self.all { + true => config.tools.keys().cloned().collect(), + false => self.plugin.clone(), + }; + + for plugin_name in plugins { + let plugin_name = unalias_plugin(&plugin_name); self.uninstall_one(&config, plugin_name, &mpr)?; } Ok(()) diff --git a/src/cli/prune.rs b/src/cli/prune.rs index 84704d61c..9b5ca1f54 100644 --- a/src/cli/prune.rs +++ b/src/cli/prune.rs @@ -23,10 +23,10 @@ use crate::ui::prompt; pub struct Prune { /// Prune only versions from these plugins #[clap()] - pub plugins: Option>, + pub plugin: Option>, /// Do not actually delete anything - #[clap(long, short_alias = 'n')] + #[clap(long, short = 'n')] pub dry_run: bool, } @@ -39,7 +39,7 @@ impl Prune { .map(|(p, tv)| (tv.to_string(), (p, tv))) .collect::, ToolVersion)>>(); - if let Some(plugins) = &self.plugins { + if let Some(plugins) = &self.plugin { to_delete.retain(|_, (_, tv)| plugins.contains(&tv.plugin_name)); } diff --git a/src/cli/render_completion.rs b/src/cli/render_completion.rs index 9b714c8c7..5a40510f1 100644 --- a/src/cli/render_completion.rs +++ b/src/cli/render_completion.rs @@ -1,17 +1,18 @@ -use clap::{Arg, ArgAction, Command, ValueHint}; +use clap::{Arg, ArgAction, Args, Command, ValueHint}; +use std::collections::HashSet; use std::io::Cursor; -use std::iter::once; use clap_complete::generate; use color_eyre::eyre::Result; use itertools::Itertools; +use once_cell::sync::Lazy; use crate::cli::self_update::SelfUpdate; use crate::config::Config; use crate::output::Output; /// Generate shell completions -#[derive(Debug, clap::Args)] +#[derive(Debug, Args)] #[clap(hide = true, verbatim_doc_comment)] pub struct RenderCompletion { /// Shell type to generate completions for @@ -30,7 +31,7 @@ impl RenderCompletion { let mut c = Cursor::new(Vec::new()); let mut cmd = crate::cli::Cli::command().subcommand(SelfUpdate::command()); - if matches!(shell, clap_complete::Shell::Zsh) { + if let clap_complete::Shell::Zsh = shell { rtxprintln!(out, "{}", ZshComplete::new(cmd).render()?.trim()); } else { generate(shell, &mut cmd, "rtx", &mut c); @@ -42,7 +43,7 @@ impl RenderCompletion { } struct ZshComplete { - cmd: clap::Command, + cmd: Command, } impl ZshComplete { @@ -52,7 +53,7 @@ impl ZshComplete { fn render(&self) -> Result { let command_funcs = self.render_command_funcs(&[&self.cmd]); - let command_descriptions = self.render_command_descriptions(); + let command_descriptions = self.render_command_descriptions(&[&self.cmd]); Ok(formatdoc! {r#" #compdef rtx @@ -66,19 +67,44 @@ impl ZshComplete { {command_funcs} {command_descriptions} + (( $+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)) + 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 "$@" + }} - _rtx "$@" + if [ "$funcstack[1]" = "_rtx" ]; then + _rtx "$@" + else + compdef _rtx rtx + fi # Local Variables: # mode: Shell-Script @@ -91,25 +117,26 @@ impl ZshComplete { } fn render_args(&self, cmds: &[&Command]) -> String { - let args = cmds + let global_args = cmds .iter() .flat_map(|cmd| cmd.get_arguments()) .filter(|arg| arg.is_global_set()); let cmd = cmds.last().unwrap(); - let args = args - .chain(cmd.get_arguments()) - .filter(|arg| !arg.is_hide_set()) + let args = cmd + .get_arguments() + .chain(global_args) + .filter(|arg| !arg.is_hide_set() && !arg.is_last_set()) .unique_by(|arg| arg.get_id()) - .sorted_by_key(|arg| (arg.get_short(), arg.get_long(), arg.get_id())) .map(|arg| self.render_arg(arg)) .collect::>() .join(" \\\n "); if cmd.has_subcommands() { let subcommands = self.render_subcommands(cmds); + let func = format!("__{}_cmds", func_name(cmds)); formatdoc! {r#" _arguments -s -S \ {args} \ - '1: :_rtx_cmds' \ + '1: :{func}' \ '*::arg:->args' && ret=0 {subcommands} @@ -128,18 +155,15 @@ impl ZshComplete { let cmd = cmds.last().unwrap(); let cases = cmd .get_subcommands() + .filter(|c| !banned(c)) .sorted_by_cached_key(|c| c.get_name()) .map(|cmd| { - let name = cmd.get_name(); let mut names = cmd.get_all_aliases().sorted().collect_vec(); - names.push(name); + names.push(cmd.get_name()); let names = names.join("|"); - let func = cmds - .iter() - .chain(once(&cmd)) - .map(|c| c.get_name()) - .join("_") - .replace('-', "_"); + let mut cmds = cmds.iter().copied().collect_vec(); + cmds.push(cmd); + let func = func_name(&cmds); format!(" ({names}) __{func}_cmd && ret=0 ;;",) }) .collect::>() @@ -157,98 +181,109 @@ impl ZshComplete { } fn render_arg(&self, arg: &clap::Arg) -> String { - if arg.get_action().takes_values() { - self.render_option(arg) - } else { - self.render_flag(arg) - } - } - - fn render_flag(&self, arg: &clap::Arg) -> String { - // print this: '(-r --raw)'{-r,--raw}'[Directly pipe stdin/stdout/stderr to user.]' \ let help = match arg.get_help() { - Some(help) => escape_single_quote(first_line(&help.to_string())).to_string(), + Some(help) => format!("[{}]", help_escape(first_line(&help.to_string()))), None => return String::new(), }; - match (arg.get_short(), arg.get_long()) { - (Some(short), Some(long)) => { - format!("'(-{short} --{long})'{{-{short},--{long}}}'[{help}]'",) - } - (Some(short), None) => { - format!("'-{short}[{help}]'",) - } - (None, Some(long)) => format!("'--{long}=[{help}]'"), - (None, None) => self.render_positional(arg), - } - } - fn render_option(&self, arg: &clap::Arg) -> String { - // print this: '(-j --jobs)'{-j,--jobs}'=[Number of plugins and runtimes to install in parallel]:: :' \ - let help = match arg.get_help() { - Some(help) => escape_single_quote(first_line(&help.to_string())).to_string(), - None => return String::new(), + let multiple = if let ArgAction::Count | ArgAction::Append = arg.get_action() { + "*" + } else { + "" }; - let completions = match arg.get_possible_values() { - values if values.is_empty() => ":: :".to_string(), - values => format!( - ": :({})", - values - .iter() - .map(|v| v.get_name()) - .collect::>() - .join(" ") - ), + let all = self.get_short_and_longs(arg); + let conflicts = if all.len() < 2 || multiple == "*" { + "".to_string() + } else { + format!("({})", all.join(" ")) }; - match (arg.get_short(), arg.get_long()) { - (Some(short), Some(long)) => { - format!("'(-{short} --{long})'{{-{short},--{long}}}'=[{help}]{completions}'",) - } - (Some(short), None) => { - format!("'-{short}[{help}]{completions}'") + let all = if all.len() < 2 { + all.join(" ") + } else { + format!("'{{{}}}'", all.join(",")) + }; + let name = arg.get_id(); + let completions = format!("{name}:{}", self.render_completion(arg)); + if arg.is_positional() { + if let ArgAction::Count | ArgAction::Append = arg.get_action() { + format!("'*::{completions}'") + } else if arg.is_required_set() || name == "new_plugin" { + format!("':{completions}'") + } else { + format!("'::{completions}'") } - (None, Some(long)) => format!("'--{long}=[{help}]{completions}'"), - (None, None) => self.render_positional(arg), + } else if arg.get_action().takes_values() { + format!("'{conflicts}{multiple}{all}={help}:{completions}'") + } else { + format!("'{conflicts}{multiple}{all}{help}'") } } - fn render_positional(&self, arg: &Arg) -> String { - let name = arg.get_id(); - let plural = if matches!(arg.get_action(), ArgAction::Append) { - "*" - } else { - "1" + fn get_short_and_longs(&self, arg: &Arg) -> Vec { + let short = arg + .get_short_and_visible_aliases() + .unwrap_or_default() + .into_iter() + .map(|s| format!("-{s}")) + .sorted(); + let long = arg + .get_long_and_visible_aliases() + .unwrap_or_default() + .into_iter() + .map(|s| format!("--{s}")) + .sorted(); + short.chain(long).collect() + } + + fn render_completion(&self, arg: &Arg) -> String { + let possible_values = arg.get_possible_values(); + if !possible_values.is_empty() { + return format!( + "({})", + possible_values + .iter() + .map(|v| escape_value(v.get_name())) + .collect::>() + .join(" ") + ); }; match arg.get_value_hint() { - ValueHint::DirPath => format!("'{plural}: :_directories'"), - ValueHint::FilePath => format!("'{plural}: :_files'"), - ValueHint::AnyPath => format!("'{plural}: :_files'"), - ValueHint::CommandString => format!("'{plural}: :_command_string -c'"), - ValueHint::ExecutablePath => format!("'{plural}: :_command_names -e'"), - ValueHint::Username => format!("'{plural}: :_users'"), - ValueHint::Hostname => format!("'{plural}: :_hosts'"), - ValueHint::Url => format!("'{plural}: :_urls'"), - ValueHint::EmailAddress => format!("'{plural}: :_email_addresses'"), - _ if name == "tool" => format!("'{plural}::{name}:__rtx_tool_versions'"), - _ => format!("'*::{name}:'"), + ValueHint::DirPath => format!("_directories"), + ValueHint::FilePath => format!("_files"), + ValueHint::AnyPath => format!("_files"), + ValueHint::CommandName => format!("_command_names -e"), + ValueHint::CommandString => format!("_cmdstring"), + ValueHint::CommandWithArguments => format!("_cmdambivalent"), + ValueHint::ExecutablePath => format!("_absolute_command_paths"), + ValueHint::Username => format!("_users"), + ValueHint::Hostname => format!("_hosts"), + ValueHint::Url => format!("_urls"), + ValueHint::EmailAddress => format!("_email_addresses"), + ValueHint::Other => format!("( )"), + _ => match arg.get_id().as_str() { + "tool" => format!("__rtx_tool_versions"), + "plugin" => format!("__rtx_plugins"), + "new_plugin" => format!("__rtx_all_plugins"), + "alias" => format!("__rtx_aliases"), + "prefix" => format!("__rtx_prefixes"), + _ => format!(""), + }, } } fn render_command_funcs(&self, cmds: &[&Command]) -> String { let cmd = cmds.last().unwrap(); cmd.get_subcommands() + .filter(|c| !banned(c)) .sorted_by_key(|c| c.get_name()) .map(|cmd| { - let func = cmds - .iter() - .chain(once(&cmd)) - .map(|c| c.get_name()) - .join("_") - .replace('-', "_"); let mut cmds = cmds.iter().copied().collect_vec(); cmds.push(cmd); + let func = func_name(&cmds); let args = self.render_args(&cmds); let subcommand_funcs = self.render_command_funcs(&cmds); (formatdoc! {r#" + (( $+functions[__{func}_cmd] )) || __{func}_cmd() {{ {args} }} @@ -261,16 +296,16 @@ impl ZshComplete { .join("\n") } - fn render_command_descriptions(&self) -> String { - let commands = self - .cmd + fn render_command_descriptions(&self, cmds: &[&Command]) -> String { + let cmd = cmds.last().unwrap(); + let commands = cmd .get_subcommands() - .filter(|c| !c.is_hide_set()) + .filter(|c| !c.is_hide_set() && !banned(c)) .sorted_by_key(|c| c.get_name()) .map(|cmd| { let name = cmd.get_name(); let about = match cmd.get_about() { - Some(about) => escape_single_quote(first_line(&about.to_string())).to_string(), + Some(about) => help_escape(first_line(&about.to_string())).to_string(), None => String::new(), }; let aliases = cmd.get_visible_aliases().sorted().collect_vec(); @@ -283,23 +318,69 @@ impl ZshComplete { }) .collect::>() .join("\n"); - formatdoc! {r#" - (( $+functions[_rtx_cmds] )) || - _rtx_cmds() {{ + let func = format!("__{}_cmds", func_name(cmds)); + let mut out = vec![formatdoc! {r#" + (( $+functions[{func}] )) || + {func}() {{ local commands; commands=( {commands} ) _describe -t commands 'command' commands "$@" - }}"#} + }}"#}]; + + for cmd in cmd + .get_subcommands() + .filter(|c| c.has_subcommands() && !banned(c)) + { + let mut cmds = cmds.iter().copied().collect_vec(); + cmds.push(cmd); + out.push(self.render_command_descriptions(&cmds)); + } + out.join("\n") } } +fn func_name(cmds: &[&Command]) -> String { + cmds.iter() + .map(|c| c.get_name()) + .join("_") + .replace('-', "_") +} + fn first_line(s: &str) -> &str { s.lines().next().unwrap_or_default() } -fn escape_single_quote(s: &str) -> String { - s.replace('\'', r"'\''") +fn help_escape(s: &str) -> String { + s.replace('\\', "\\\\") + .replace('\'', "'\\''") + .replace('[', "\\[") + .replace(']', "\\]") + .replace(':', "\\:") + .replace('$', "\\$") + .replace('`', "\\`") +} + +/// Escape value string inside single quotes and parentheses +fn escape_value(string: &str) -> String { + string + .replace('\\', "\\\\") + .replace('\'', "'\\''") + .replace('[', "\\[") + .replace(']', "\\]") + .replace(':', "\\:") + .replace('$', "\\$") + .replace('`', "\\`") + .replace('(', "\\(") + .replace(')', "\\)") + .replace(' ', "\\ ") +} + +static BANNED_COMMANDS: Lazy> = + Lazy::new(|| ["render-mangen", "render-help", "render-completion"].into()); + +fn banned(cmd: &Command) -> bool { + BANNED_COMMANDS.contains(&cmd.get_name()) } #[cfg(test)] diff --git a/src/cli/settings/set.rs b/src/cli/settings/set.rs index 48b916b0f..a155b3283 100644 --- a/src/cli/settings/set.rs +++ b/src/cli/settings/set.rs @@ -11,6 +11,7 @@ use crate::output::Output; #[clap(visible_aliases = ["add", "create"], after_long_help = AFTER_LONG_HELP, verbatim_doc_comment)] pub struct SettingsSet { /// The setting to set + #[clap()] pub key: String, /// The value to set pub value: String,