mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-19 05:58:43 -04:00
Issue #4 and #12: Check for presence of candidate and version. Also bolstered list and use commands.
This commit is contained in:
@@ -18,9 +18,8 @@ Feature: Command Line Interop
|
||||
|
||||
Scenario: Enter an invalid Candidate
|
||||
When I enter "gvm install groffle"
|
||||
Then I see "Invalid candidate: groffle"
|
||||
And I see "Usage: gvm <command> <candidate> [version]"
|
||||
Then I see "Stop! groffle is not a valid candidate."
|
||||
|
||||
Scenario: Use without providing a Candidate
|
||||
When I enter "gvm use"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
|
||||
@@ -19,4 +19,16 @@ Feature: Uninstall Candidate
|
||||
When I enter "gvm uninstall grails 1.3.9"
|
||||
Then I see "grails 1.3.9 is not installed."
|
||||
And the candidate "grails" version "1.3.9" is not installed
|
||||
|
||||
Scenario: Attempt uninstalling with no Candidate specified
|
||||
When I enter "gvm uninstall"
|
||||
Then I see "No candidate provided."
|
||||
|
||||
Scenario: Attempt uninstalling with an invalid Candidate specified
|
||||
When I enter "gvm uninstall groffle"
|
||||
Then I see "Stop! groffle is not a valid candidate."
|
||||
|
||||
Scenario: Attempt uninstalling without a version provided
|
||||
When I enter "gvm uninstall grails"
|
||||
Then I see "No candidate version provided."
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class VertxUtils {
|
||||
final static candidates = [grails:grails]
|
||||
final static defaults = [grails:'2.1.0']
|
||||
|
||||
static final gvmVersion = '0.1'
|
||||
static final gvmVersion = '0.3'
|
||||
static final serverVersion = '0.1'
|
||||
static final vertxVersion = '1.2.3.final'
|
||||
|
||||
@@ -93,7 +93,7 @@ class VertxUtils {
|
||||
binding = [server:serverVersion, vertx:vertxVersion]
|
||||
} else {
|
||||
gtplFile = new File('srv/templates/upgrade.gtpl')
|
||||
binding = [version:gvmVersion]
|
||||
binding = [version:version, gvmVersion:gvmVersion]
|
||||
}
|
||||
def template = templateEngine.createTemplate(gtplFile).make(binding)
|
||||
req.response.end template.toString()
|
||||
|
||||
@@ -26,6 +26,14 @@ function check_candidate_present {
|
||||
fi
|
||||
}
|
||||
|
||||
function check_version_present {
|
||||
if [ -z "$1" ]; then
|
||||
echo -e "\nNo candidate version provided."
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
function determine_candidate_version {
|
||||
if [ -z "$1" ]; then
|
||||
VERSION=$(curl -s "$GVM_SERVICE/candidates/$CANDIDATE/default")
|
||||
@@ -168,11 +176,7 @@ function gvm-install {
|
||||
|
||||
function gvm-use {
|
||||
CANDIDATE="$1"
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
check_candidate_present "$CANDIDATE"
|
||||
|
||||
determine_candidate_version "$2"
|
||||
check_not_installed
|
||||
@@ -187,6 +191,7 @@ function gvm-use {
|
||||
|
||||
function gvm-list {
|
||||
CANDIDATE="$1"
|
||||
check_candidate_present "$CANDIDATE"
|
||||
build_version_csv "$CANDIDATE"
|
||||
determine_current_version "$CANDIDATE"
|
||||
FRAGMENT=$(curl -s "$GVM_SERVICE/candidates/$CANDIDATE/list?current=$CURRENT&installed=$CSV")
|
||||
@@ -196,6 +201,8 @@ function gvm-list {
|
||||
function gvm-uninstall {
|
||||
CANDIDATE="$1"
|
||||
VERSION="$2"
|
||||
check_candidate_present "$CANDIDATE"
|
||||
check_version_present "$VERSION"
|
||||
CURRENT=$(readlink "$GVM_DIR/$CANDIDATE/current" | sed -e "s_$GVM_DIR/$CANDIDATE/__g")
|
||||
if [ -h "$GVM_DIR/$CANDIDATE/current" -a "$VERSION" == "$CURRENT" ]; then
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user