asdf/lib/commands/uninstall.sh

30 lines
796 B
Bash
Raw Normal View History

2015-05-17 00:46:56 -07:00
uninstall_command() {
local package_name=$1
local full_version=$2
local source_path=$(get_source_path $package_name)
2015-05-07 22:58:07 -07:00
2015-05-17 00:46:56 -07:00
check_if_source_exists $source_path
2015-05-07 22:58:07 -07:00
2015-05-17 00:46:56 -07:00
IFS=':' read -a version_info <<< "$full_version"
2015-05-17 03:47:45 -07:00
if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then
2015-05-17 00:46:56 -07:00
local install_type="${version_info[0]}"
local version="${version_info[1]}"
else
local install_type="version"
local version="${version_info[0]}"
fi
2015-05-07 22:58:07 -07:00
2015-05-17 00:46:56 -07:00
local install_path=$(get_install_path $package_name $install_type $version)
2015-05-07 22:58:07 -07:00
2015-05-17 03:47:45 -07:00
if [ ! -d $install_path ]; then
2015-05-17 00:46:56 -07:00
display_error "No such version"
exit 1
fi
2015-05-16 21:28:14 -07:00
2015-05-17 03:47:45 -07:00
if [ -f ${source_path}/bin/uninstall ]; then
2015-05-17 00:46:56 -07:00
${source_path}/bin/uninstall $install_type $version $install_path "${@:3}"
else
rm -rf $install_path
fi
}