From 2d255344c22c966cdcbce3bb8600a99959ebdd11 Mon Sep 17 00:00:00 2001 From: Yasuharu Nakano Date: Mon, 9 Mar 2015 20:58:36 +0900 Subject: [PATCH] Add "Outdated:" label and up-to-date message to 'outdated' command. --- src/main/bash/gvm-outdated.sh | 19 +++++++++++++++---- .../cucumber/gvm/outdated_candidate.feature | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/bash/gvm-outdated.sh b/src/main/bash/gvm-outdated.sh index cb75b0a9..cb00005e 100644 --- a/src/main/bash/gvm-outdated.sh +++ b/src/main/bash/gvm-outdated.sh @@ -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 } diff --git a/src/test/cucumber/gvm/outdated_candidate.feature b/src/test/cucumber/gvm/outdated_candidate.feature index 8fa8a5fa..f8609aad 100644 --- a/src/test/cucumber/gvm/outdated_candidate.feature +++ b/src/test/cucumber/gvm/outdated_candidate.feature @@ -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"