diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d361400..7cf8a40b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ Features slower `get_preset_version_for` which takes legacy formats into account. * Shim exec recommends which plugins or versions to set when command is not found. * `asdf reshim` without arguments now reshims all installed plugins (#407) +* Add `asdf shim-versions ` to list on which plugins and versions is a command + available. (#380) Fixed Bugs diff --git a/bin/asdf b/bin/asdf index e064320e..0c0d8a26 100755 --- a/bin/asdf +++ b/bin/asdf @@ -17,6 +17,8 @@ source "$(dirname "$(dirname "$0")")/lib/commands/current.sh" source "$(dirname "$(dirname "$0")")/lib/commands/where.sh" # shellcheck source=lib/commands/which.sh source "$(dirname "$(dirname "$0")")/lib/commands/which.sh" +# shellcheck source=lib/commands/shim_versions.sh +source "$(dirname "$(dirname "$0")")/lib/commands/shim_versions.sh" # shellcheck source=lib/commands/version_commands.sh source "$(dirname "$(dirname "$0")")/lib/commands/version_commands.sh" # shellcheck source=lib/commands/list.sh @@ -83,9 +85,6 @@ case $1 in "list-all") list_all_command $callback_args;; -"shim") - shim_command $callback_args;; - "reshim") reshim_command $callback_args;; @@ -111,6 +110,8 @@ case $1 in "plugin-test") plugin_test_command $callback_args;; +"shim-versions") + shim_versions_command $callback_args;; *) help_command exit 1;; diff --git a/help.txt b/help.txt index 2896aa0e..4d88644e 100644 --- a/help.txt +++ b/help.txt @@ -17,7 +17,7 @@ MANAGE PACKAGES asdf current Display current version set or being used for all packages asdf current Display current version set or being used for package asdf where [] Display install path for an installed or current version - asdf which Display install path for current version + asdf which Display the path to an executable asdf local Set the package local version asdf global Set the package global version asdf list List installed versions of a package @@ -26,6 +26,7 @@ MANAGE PACKAGES UTILS asdf reshim Recreate shims for version of a package + asdf shim-versions List on which plugins and versions is an executable provided. asdf update Update asdf to the latest stable release asdf update --head Update asdf to the latest on the master branch diff --git a/lib/commands/shim_versions.sh b/lib/commands/shim_versions.sh new file mode 100644 index 00000000..f2cbe7ad --- /dev/null +++ b/lib/commands/shim_versions.sh @@ -0,0 +1,4 @@ +shim_versions_command() { + local shim_name=$1 + shim_plugin_versions "$shim_name" +} diff --git a/test/shim_versions_command.bats b/test/shim_versions_command.bats new file mode 100644 index 00000000..367e27ed --- /dev/null +++ b/test/shim_versions_command.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats + +load test_helpers + +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/shim_versions.sh +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh + +setup() { + setup_asdf_dir + install_dummy_plugin + + PROJECT_DIR=$HOME/project + mkdir -p $PROJECT_DIR + cd $PROJECT_DIR +} + +teardown() { + clean_asdf_dir +} + +@test "shim_versions_command should list plugins and versions where command is available" { + cd $PROJECT_DIR + run install_command dummy 3.0 + run install_command dummy 1.0 + run reshim_command dummy + + run shim_versions_command dummy + [ "$status" -eq 0 ] + + echo "$output" | grep "dummy 3.0" + echo "$output" | grep "dummy 1.0" +}