aboutsummaryrefslogtreecommitdiffstats
path: root/kerl
diff options
context:
space:
mode:
authorMark Allen <[email protected]>2017-02-20 15:17:52 -0600
committerGitHub <[email protected]>2017-02-20 15:17:52 -0600
commit485323434eb3992dacb6442177a7d848b82af113 (patch)
tree602f163f7ead50cf5795302136d07767e907d1dc /kerl
parent69579330e765ff2a97e75d04ba0a4d0ebedf23d0 (diff)
parent23acfaba005c2dade4c80ccdb98fd27fab95ea9a (diff)
downloadkerl-485323434eb3992dacb6442177a7d848b82af113.tar.gz
kerl-485323434eb3992dacb6442177a7d848b82af113.tar.bz2
kerl-485323434eb3992dacb6442177a7d848b82af113.zip
Merge pull request #183 from kerl/enable-travis-ci
Enable travis-CI, add 'kerl path' subcommand
Diffstat (limited to 'kerl')
-rwxr-xr-xkerl38
1 files changed, 38 insertions, 0 deletions
diff --git a/kerl b/kerl
index 98cefb2..d053bd9 100755
--- a/kerl
+++ b/kerl
@@ -1229,6 +1229,11 @@ list_has()
return 1
}
+path_usage()
+{
+ echo "usage: $0 path [<install_name>]"
+}
+
list_usage()
{
echo "usage: $0 list <releases|builds|installations>"
@@ -1549,6 +1554,39 @@ case "$1" in
;;
esac
;;
+ path)
+ # Usage:
+ # kerl path
+ # # Print currently active installation path, else non-zero exit
+ # kerl path <install>
+ # Print path to installation with name <install>, else non-zero exit
+ if [ -z "$2" ]; then
+ activepath=$(get_active_path)
+ if [ -z "$activepath" ]; then
+ echo "No active kerl-managed erlang installation"
+ exit 1
+ fi
+ echo "$activepath"
+ else
+ # There are some possible extensions to this we could
+ # consider, such as:
+ # - if 2+ matches: prefer one in a subdir from $PWD
+ # - prefer $KERL_DEFAULT_INSTALL_DIR
+ match=
+ for ins in $(list_print installations | cut -d' ' -f2); do
+ if [ "$(basename $ins)" = "$2" ]; then
+ if [ -z "$match" ]; then
+ match="$ins"
+ else
+ echo "Error: too many matching installations" >&2
+ exit 2
+ fi
+ fi
+ done
+ [ -n "$match" ] && echo "$match" && exit 0
+ echo "Error: no matching installation found" >&2 && exit 1
+ fi
+ ;;
delete)
if [ $# -ne 3 ]; then
delete_usage