From d037628e7e2d20e2cf2837198e51a2cc641bf7a4 Mon Sep 17 00:00:00 2001 From: Akash Manohar J Date: Wed, 27 May 2015 12:13:10 +0530 Subject: [PATCH] Add which command --- bin/asdf | 4 ++++ lib/commands/which.sh | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 lib/commands/which.sh diff --git a/bin/asdf b/bin/asdf index 995b3c9a..dd3ece7e 100755 --- a/bin/asdf +++ b/bin/asdf @@ -5,6 +5,7 @@ source $(dirname $(dirname $0))/lib/utils.sh source $(dirname $(dirname $0))/lib/commands/help.sh source $(dirname $(dirname $0))/lib/commands/install.sh source $(dirname $(dirname $0))/lib/commands/uninstall.sh +source $(dirname $(dirname $0))/lib/commands/which.sh source $(dirname $(dirname $0))/lib/commands/list.sh source $(dirname $(dirname $0))/lib/commands/list-all.sh source $(dirname $(dirname $0))/lib/commands/reshim.sh @@ -31,6 +32,9 @@ case $1 in "uninstall") uninstall_command $callback_args;; +"which") + which_command $callback_args;; + "list") list_command $callback_args;; diff --git a/lib/commands/which.sh b/lib/commands/which.sh new file mode 100644 index 00000000..68fb22d1 --- /dev/null +++ b/lib/commands/which.sh @@ -0,0 +1,15 @@ +which_command() { + local plugin_name=$1 + local plugin_path=$(get_plugin_path $plugin_name) + check_if_plugin_exists $plugin_path + + full_version=$(get_preset_version_for $plugin_name) + + if [ "$full_version" == "" ]; then + echo "No version set for ${plugin_name}" + exit -1 + else + echo "$full_version" + exit 0 + fi +}