mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Initial support for which command
This commit is contained in:
parent
028699a7ea
commit
fb4e263598
4
bin/asdf
4
bin/asdf
@ -7,6 +7,7 @@ source $(dirname $(dirname $0))/lib/commands/install.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/uninstall.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/current.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/where.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/which.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/version_commands.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/list.sh
|
||||
source $(dirname $(dirname $0))/lib/commands/list-all.sh
|
||||
@ -42,6 +43,9 @@ case $1 in
|
||||
"where")
|
||||
where_command $callback_args;;
|
||||
|
||||
"which")
|
||||
which_command $callback_args;;
|
||||
|
||||
"local")
|
||||
local_command $callback_args;;
|
||||
|
||||
|
@ -32,7 +32,7 @@ _asdf () {
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall current where list list-all reshim'
|
||||
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall current where which list list-all reshim'
|
||||
COMPREPLY=($(compgen -W "$cmds" -- $cur))
|
||||
;;
|
||||
esac
|
||||
|
1
help.txt
1
help.txt
@ -13,6 +13,7 @@ MANAGE PACKAGES
|
||||
asdf uninstall <name> <version> Remove a specific version of a package
|
||||
asdf current <name> Display current version set or being used for package
|
||||
asdf where <name> <version> Display install path for an installed version
|
||||
asdf which <name> Display install path for current version
|
||||
asdf local <name> <version> Set the package local version
|
||||
asdf global <name> <version> Set the package global version
|
||||
asdf list <name> List installed versions of a package
|
||||
|
36
lib/commands/which.sh
Normal file
36
lib/commands/which.sh
Normal file
@ -0,0 +1,36 @@
|
||||
current_version() {
|
||||
local plugin_name=$1
|
||||
|
||||
check_if_plugin_exists $plugin_name
|
||||
|
||||
local search_path=$(pwd)
|
||||
local version_and_path=$(find_version "$plugin_name" "$search_path")
|
||||
local version=$(cut -d '|' -f 1 <<< "$version_and_path");
|
||||
local version_file_path=$(cut -d '|' -f 2 <<< "$version_and_path");
|
||||
|
||||
check_if_version_exists $plugin_name $version
|
||||
check_for_deprecated_plugin $plugin_name
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo "No version set for $plugin_name"
|
||||
exit 1
|
||||
else
|
||||
echo "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
which_command() {
|
||||
local plugin_name=$1
|
||||
local plugin_path=$(get_plugin_path $plugin_name)
|
||||
check_if_plugin_exists $plugin_name
|
||||
|
||||
local install_path=$(get_install_path $plugin_name $install_type $(current_version))
|
||||
|
||||
if [ -d $install_path ]; then
|
||||
echo $install_path/$plugin_name
|
||||
exit 0
|
||||
else
|
||||
echo "Version not installed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
Loading…
Reference in New Issue
Block a user