Better error output when trying to 'gvm use' a version that

isn't installed. Fixes issue #15
This commit is contained in:
Joshua Bussdieker
2012-07-18 12:28:58 -07:00
parent 292e24e1ea
commit 0eb9feb2aa
2 changed files with 13 additions and 4 deletions
+12 -3
View File
@@ -1,9 +1,18 @@
#!/bin/bash
function gvm_use() {
[[ "$1" != "" ]] ||
[[ "$1" != "" ]] ||
display_error "Please specifiy the version" || return 1
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1"` ||
display_error "Invalid version $1" || return 1
VERSION=$1
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1"`
if [[ "$?" != "0" ]]; then
GO_CACHE_PATH=$GVM_ROOT/archive/go
version=`hg tags -R $GO_CACHE_PATH | awk '{print $1}' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH "$VERSION"`
if [[ "x$version" == "x" ]]; then
display_error "Version not found locally. Try 'gvm install $1'" || return 1
else
display_warning "$version is not installed. Install it by running 'gvm install $version'" || return 1
fi
fi
export PATH=$GVM_PATH_BACKUP
. $GVM_ROOT/environments/$fuzzy_match &> /dev/null || display_error "Couldn't source environment" || return 1
+1 -1
View File
@@ -4,7 +4,7 @@ display_warning() {
# YELLOW!
tput sgr0
tput setaf 3
echo "$1"
echo "WARNING: $1"
tput sgr0
else
echo "$1"