From cdee09dec38b4e55e04348124f9a8b7025e0ebf4 Mon Sep 17 00:00:00 2001 From: Akash Manohar J Date: Sun, 30 Nov 2014 15:48:49 +0530 Subject: [PATCH] Cleanup readme --- README.md | 15 +++++++++------ lib/asdf.sh | 42 +++++++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8287fe1f..caf22cb9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ asdf source-remove asdf source-update asdf source-update -## `.asdf-versions` file + +## `.versions` file ``` elixir 1.0.0 @@ -25,10 +26,12 @@ erlang 17.3 ## Package source structure -A package source is a git repo, with the following files +A package source is a git repo, with the following executable scripts -* `bin/install` -* `bin/uninstall` -* `bin/use` +* `bin/list-all` - lists all installable versions +* `bin/install` - installs the specified version +* `bin/uninstall` - uninstalls the specified version +* `bin/use` - uses the specified version (and also adds the version to `.versions` file in the dir) -These scripts are run when `package install`, `package uninstall` or `package use` commands are run. You can set or unset env vars, + +These scripts are run when `list-all`, `install`, `uninstall` or `use` commands are run. You can set or unset env vars, diff --git a/lib/asdf.sh b/lib/asdf.sh index 7a3b13af..4f199646 100755 --- a/lib/asdf.sh +++ b/lib/asdf.sh @@ -1,10 +1,11 @@ run_command() { local callback_args="${@:2}" - run_callback_if_command "--version" $1 asdf_version $callback_args - run_callback_if_command "install" $1 install_command $callback_args - run_callback_if_command "list" $1 list_command $callback_args - run_callback_if_command "list-all" $1 list_all_command $callback_args - run_callback_if_command "help" $1 help_command $callback_args + run_callback_if_command "--version" $1 asdf_version $callback_args + run_callback_if_command "install" $1 install_command $callback_args + run_callback_if_command "uninstall" $1 uninstall_command $callback_args + run_callback_if_command "list" $1 list_command $callback_args + run_callback_if_command "list-all" $1 list_all_command $callback_args + run_callback_if_command "help" $1 help_command $callback_args help_command @@ -30,7 +31,34 @@ install_command() { fi local install_path=$(get_install_path $package $full_version) - ${source_path}/install $install_type $version $install_path "${@:3}" + ${source_path}/bin/install $install_type $version $install_path "${@:3}" +} + + +uninstall_command() { + local package=$1 + local full_version=$2 + local source_path=$(get_source_path $package) + + check_if_source_exists $source_path + if [ ! -d "$source_path/$full_version" ] + then + display_error "No such version" + exit 1 + fi + + IFS=':' read -a version_info <<< "$full_version" + if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ] + then + local install_type="${version_info[0]}" + local version="${version_info[1]}" + else + local install_type="version" + local version="${version_info[0]}" + fi + + local install_path=$(get_install_path $package $full_version) + ${source_path}/bin/uninstall $install_type $version $install_path "${@:3}" } @@ -46,7 +74,7 @@ get_install_path() { list_all_command() { local source_path=$(get_source_path $1) check_if_source_exists $source_path - ${source_path}/list-all + ${source_path}/bin/list-all }