mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-04-30 20:12:45 -04:00
Added install feature with gvm implementation.
This commit is contained in:
53
bin/gvm
53
bin/gvm
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
GVM_DIR="$HOME/.gvm"
|
||||
GVM_SERVICE="http://localhost:8080/gvm-service"
|
||||
|
||||
if [ ! -d "$GVM_DIR" ]; then
|
||||
mkdir "$GVM_DIR"
|
||||
@@ -9,20 +10,58 @@ if [ ! -d "$GVM_DIR" ]; then
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "$1" == "help" -o -z "$1" -o -z "$2" ]; then
|
||||
echo "Usage: gvm <command> <candidate> [version]"
|
||||
echo " commands: install, uninstall, list, use or help"
|
||||
echo " candidate: groovy, grails, griffon or gradle"
|
||||
echo " version: defaults to latest stable if not provided"
|
||||
if [ ! $(which curl) ]; then
|
||||
echo "Please install curl through your package manager before using this tool."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" == "help" -o -z "$1" -o -z "$2" ]; then
|
||||
echo "Usage: gvm <command> <candidate> [version]"
|
||||
echo ""
|
||||
echo " commands : install, uninstall, list, use or help"
|
||||
echo " candidate : groovy, grails, griffon or gradle"
|
||||
echo " version : defaults to latest stable if not provided"
|
||||
echo ""
|
||||
echo "eg: gvm install grails 2.1.0"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
function download {
|
||||
CANDIDATE="$1"
|
||||
VERSION="$2"
|
||||
echo "Downloading $CANDIDATE $VERSION"
|
||||
curl -L "$GVM_SERVICE/$CANDIDATE/download/$VERSION" >> "/tmp/$CANDIDATE-$VERSION.zip"
|
||||
}
|
||||
|
||||
function gvm-install {
|
||||
echo Installing: "$1"
|
||||
CANDIDATE="$1"
|
||||
if [ -z "$2" ]; then
|
||||
VERSION=$(curl "$GVM_SERVICE/$CANDIDATE/version")
|
||||
else
|
||||
VERSION=$(curl "$GVM_SERVICE/$CANDIDATE/version/$2")
|
||||
fi
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo ""
|
||||
echo "Stop! $2 is not a valid grails version."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Downloading: $CANDIDATE $VERSION"
|
||||
download "$CANDIDATE" "$VERSION"
|
||||
echo "Installing: $CANDIDATE $VERSION"
|
||||
mkdir -p "$GVM_DIR/$CANDIDATE"
|
||||
unzip -q "/tmp/$CANDIDATE-$VERSION.zip" -d "/tmp/"
|
||||
mv -v "/tmp/$CANDIDATE-$VERSION" "$GVM_DIR/$CANDIDATE/$VERSION"
|
||||
rm "/tmp/$CANDIDATE-$VERSION.zip"
|
||||
echo "Done installing!"
|
||||
echo ""
|
||||
echo "Start using $CANDIDATE $VERSION by issuing the following command:"
|
||||
echo " gvm use $CANDIDATE $VERSION"
|
||||
}
|
||||
|
||||
function gvm-use {
|
||||
echo Using: "$1"
|
||||
}
|
||||
|
||||
gvm-"$1" "$2"
|
||||
gvm-"$1" "$2" "$3"
|
||||
|
||||
@@ -15,10 +15,6 @@ Feature: Command Line Interop
|
||||
When I enter "gvm install"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
|
||||
Scenario: Install a Candidate
|
||||
When I enter "gvm install grails"
|
||||
Then I see "Installing: grails"
|
||||
|
||||
Scenario: Use without providing a Candidate
|
||||
When I enter "gvm use"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
|
||||
@@ -10,4 +10,4 @@ Feature: Initialisation
|
||||
Given an initialised system
|
||||
When I enter "gvm"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
And the ".gvm" folder exists in user home
|
||||
And the ".gvm" folder exists in user home
|
||||
16
src/test/cucumber/gvm/installation.feature
Normal file
16
src/test/cucumber/gvm/installation.feature
Normal file
@@ -0,0 +1,16 @@
|
||||
Feature: Installation
|
||||
|
||||
Scenario: Install a default Candidate
|
||||
Given the default "grails" candidate is "2.1.0"
|
||||
When I enter "gvm install grails"
|
||||
Then the candidate "grails" version "2.1.0" is installed
|
||||
And I see "Done installing!"
|
||||
|
||||
Scenario: Install a specific Candidate
|
||||
When I enter "gvm install grails 1.3.9"
|
||||
Then the candidate "grails" version "1.3.9" is installed
|
||||
And I see "Done installing!"
|
||||
|
||||
Scenario: Install a Candidate version that does not exist
|
||||
When I enter "gvm install grails 1.4.4"
|
||||
Then I see "Stop! 1.4.4 is not a valid grails version."
|
||||
7
src/test/resources/gvm/installation_steps.groovy
Normal file
7
src/test/resources/gvm/installation_steps.groovy
Normal file
@@ -0,0 +1,7 @@
|
||||
import static cucumber.runtime.groovy.EN.*
|
||||
import cucumber.runtime.PendingException
|
||||
|
||||
Then(~'^the candidate can be found at "([^"]*)"$') { String path ->
|
||||
def file = new File(path)
|
||||
assert file.exists(), "$path does not exist!"
|
||||
}
|
||||
Reference in New Issue
Block a user