mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-01-31 01:32:55 -05:00
Add "Outdated:" label and up-to-date message to 'outdated' command.
This commit is contained in:
@@ -23,7 +23,7 @@ function __gvmtool_determine_outdated_version {
|
||||
}
|
||||
|
||||
function __gvmtool_outdated {
|
||||
local all candidates candidate outdated installed_count
|
||||
local all candidates candidate outdated installed_count outdated_count
|
||||
if [ -n "$1" ]; then
|
||||
all=false
|
||||
candidates=$1
|
||||
@@ -32,6 +32,7 @@ function __gvmtool_outdated {
|
||||
candidates=${GVM_CANDIDATES[@]}
|
||||
fi
|
||||
installed_count=0
|
||||
outdated_count=0
|
||||
for candidate in ${candidates}; do
|
||||
outdated="$(__gvmtool_determine_outdated_version "${candidate}")"
|
||||
case $? in
|
||||
@@ -44,12 +45,22 @@ function __gvmtool_outdated {
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
[ -n "${outdated}" ] && echo "${outdated}"
|
||||
if [ -n "${outdated}" ]; then
|
||||
[ ${installed_count} -eq 0 ] && echo "Outdated:"
|
||||
echo "${outdated}"
|
||||
(( outdated_count += 1 ))
|
||||
fi
|
||||
(( installed_count += 1 ))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if $all && [ ${installed_count} -eq 0 ]; then
|
||||
echo 'No candidates are in use'
|
||||
if $all; then
|
||||
if [ ${installed_count} -eq 0 ]; then
|
||||
echo 'No candidates are in use'
|
||||
elif [ ${outdated_count} -eq 0 ]; then
|
||||
echo "All candidates are up-to-date"
|
||||
fi
|
||||
elif [ ${outdated_count} -eq 0 ]; then
|
||||
echo "${candidate} is up-to-date"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -8,13 +8,14 @@ Feature: Outdated Candidate
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
And the default "grails" candidate is "2.4.4"
|
||||
When I enter "gvm outdated grails"
|
||||
Then I see "grails (1.3.9 < 2.4.4)"
|
||||
Then I see "Outdated:"
|
||||
And I see "grails (1.3.9 < 2.4.4)"
|
||||
|
||||
Scenario: Display outdated candidate version in use when it is not outdated
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
And the default "grails" candidate is "1.3.9"
|
||||
When I enter "gvm outdated grails"
|
||||
Then I do not see "grails"
|
||||
Then I see "grails is up-to-date"
|
||||
|
||||
Scenario: Display outdated candidate version when none is in use
|
||||
Given the candidate "grails" does not exist
|
||||
@@ -30,7 +31,8 @@ Feature: Outdated Candidate
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
And the default "grails" candidate is "2.4.4"
|
||||
When I enter "gvm outdated"
|
||||
Then I see "grails (1.3.9 < 2.4.4)"
|
||||
Then I see "Outdated:"
|
||||
And I see "grails (1.3.9 < 2.4.4)"
|
||||
|
||||
Scenario: Display outdated candidate versions when none is specified and multiple are in use
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
@@ -38,6 +40,14 @@ Feature: Outdated Candidate
|
||||
And the candidate "groovy" version "2.0.5" is already installed and default
|
||||
And the default "groovy" candidate is "2.4.1"
|
||||
When I enter "gvm outdated"
|
||||
Then I see "grails (1.3.9 < 2.4.4)"
|
||||
Then I see "Outdated:"
|
||||
And I see "grails (1.3.9 < 2.4.4)"
|
||||
And I see "groovy (2.0.5 < 2.4.1)"
|
||||
|
||||
Scenario: Display outdated candidate versions when none is specified and multiple are in use but they are not outdated
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
And the default "grails" candidate is "1.3.9"
|
||||
And the candidate "groovy" version "2.0.5" is already installed and default
|
||||
And the default "groovy" candidate is "2.0.5"
|
||||
When I enter "gvm outdated"
|
||||
Then I see "All candidates are up-to-date"
|
||||
|
||||
Reference in New Issue
Block a user