From a9da2888bc1bbc23c6e6cdcdb4cf3c0d6bbde7f8 Mon Sep 17 00:00:00 2001 From: Peter Ledbrook Date: Thu, 11 Oct 2012 12:14:56 +0100 Subject: [PATCH] Add 'current' command to show version in use. --- src/test/cucumber/gvm/use_candidate.feature | 13 +++++++++++++ src/test/resources/gvm/env.groovy | 5 +++++ srv/scripts/gvm | 14 ++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/test/cucumber/gvm/use_candidate.feature b/src/test/cucumber/gvm/use_candidate.feature index e8f52f7b..8ee8f1be 100644 --- a/src/test/cucumber/gvm/use_candidate.feature +++ b/src/test/cucumber/gvm/use_candidate.feature @@ -24,3 +24,16 @@ Feature: Use Candidate And the candidate "grails" version "1.3.9" is in use When I enter "gvm use grails 2.1.0" Then the candidate "grails" version "2.1.0" should be in use + + Scenario: Display current candidate version in use + Given the candidate "grails" version "2.1.0" is already installed + Given the candidate "grails" version "1.3.9" is already installed + And the candidate "grails" version "1.3.9" is in use + When I enter "gvm current grails" + Then I see "Using grails version 1.3.9" + + Scenario: Display current candidate version when none is in use + Given the candidate "grails" version "2.1.0" is already installed + Given the candidate "grails" version "1.3.9" is already installed + When I enter "gvm current grails" + Then I see "Not using any version of grails" diff --git a/src/test/resources/gvm/env.groovy b/src/test/resources/gvm/env.groovy index 398f99d6..f020f26c 100644 --- a/src/test/resources/gvm/env.groovy +++ b/src/test/resources/gvm/env.groovy @@ -1,6 +1,11 @@ import static cucumber.runtime.groovy.Hooks.* import static gvm.VertxUtils.* +def gvmDir = System.getenv('GVM_DIR') +if (!gvmDir) { + throw new RuntimeException("You must have the GVM_DIR environment variable set to run the tests") +} + gvmDir = new File(System.getenv('GVM_DIR')) server = null diff --git a/srv/scripts/gvm b/srv/scripts/gvm index 2bf187b8..6df135ba 100755 --- a/srv/scripts/gvm +++ b/srv/scripts/gvm @@ -11,7 +11,7 @@ function help { echo "" echo "Usage: gvm [version]" echo "" - echo " command : install, uninstall, list, use, selfupdate or help" + echo " command : install, uninstall, list, use, current, selfupdate or help" echo " candidate : $CANDIDATES" echo " version : optional, defaults to latest stable if not provided" echo "" @@ -139,7 +139,7 @@ if [ "$1" == "help" -o -z "$1" ]; then exit 0 fi -if [ "$1" != "install" -a "$1" != "use" -a "$1" != "uninstall" -a "$1" != "list" -a "$1" != "help" -a "$1" != "selfupdate" ]; then +if [ "$1" != "install" -a "$1" != "use" -a "$1" != "uninstall" -a "$1" != "list" -a "$1" != "current" -a "$1" != "help" -a "$1" != "selfupdate" ]; then echo -e "\nInvalid command: $1" help exit 0 @@ -189,6 +189,16 @@ function gvm-use { echo Using "$CANDIDATE" version "$VERSION" } +function gvm-current { + CANDIDATE="$1" + determine_current_version "$CANDIDATE" + if [ -n "$CURRENT" ]; then + echo Using "$CANDIDATE" version "$CURRENT" + else + echo Not using any version of "$CANDIDATE" + fi +} + function gvm-list { CANDIDATE="$1" check_candidate_present "$CANDIDATE"