- implode function + confirmation prompt when invoking gvm implode

- test case
This commit is contained in:
Ali Abbas
2014-04-12 15:57:26 +02:00
parent b38be0c606
commit e27f83653f
5 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ fi
command=$1
if [[ $command == "implode" ]]; then
rm -rf "$GVM_ROOT"
gvm_implode
exit 0
fi
+2 -1
View File
@@ -26,7 +26,8 @@ function gvm() {
shift
gvm_use "$@"
elif [[ "$1" == "implode" ]]; then
rm -rf "$GVM_ROOT"
. "$GVM_ROOT/scripts/env/implode"
gvm_implode
elif [[ "$1" == "pkgset" ]] && [[ "$2" == "use" ]]; then
. "$GVM_ROOT/scripts/env/pkgset-use"
shift
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
function gvm_implode() {
read -p "Are you sure? [Y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
display_message "Action cancelled"
else
(rm -rf "$GVM_ROOT" && display_message "GVM successfully removed") || display_error "Failed to uninstall gvm"
fi
}
+1
View File
@@ -95,6 +95,7 @@ create_enviroment() {
echo "export DYLD_LIBRARY_PATH; DYLD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${DYLD_LIBRARY_PATH}\"" >> "$new_env_file"
echo "export PKG_CONFIG_PATH; PKG_CONFIG_PATH=\"\${GVM_OVERLAY_PREFIX}/lib/pkgconfig:\${PKG_CONFIG_PATH}\"" >> "$new_env_file"
. "$GVM_ROOT/scripts/env/use"
. "$GVM_ROOT/scripts/env/implode"
gvm_use "$GO_NAME" &> /dev/null ||
display_fatal "Failed to use installed version"
gvm pkgset create global
+3
View File
@@ -0,0 +1,3 @@
source $GVM_ROOT/scripts/gvm
yes n | gvm implode # status=0; match=/Action cancelled/
yes | gvm implode # status=0; match=/GVM successfully removed/