diff --git a/src/main/bash/sdkman-list.sh b/src/main/bash/sdkman-list.sh index 53e91c43..d13b1126 100644 --- a/src/main/bash/sdkman-list.sh +++ b/src/main/bash/sdkman-list.sh @@ -68,7 +68,11 @@ function __sdkman_list { } function __sdkman_list_candidates { - echo "$(curl -s "${SDKMAN_SERVICE}/candidates/list")" | ${PAGER-less} + if [[ "${SDKMAN_AVAILABLE}" == "false" ]]; then + echo "This command is not available while offline." + else + echo "$(curl -s "${SDKMAN_SERVICE}/candidates/list")" | ${PAGER-less} + fi } function __sdkman_list_versions { diff --git a/src/test/cucumber/service_unavailable.feature b/src/test/cucumber/service_unavailable.feature index ed22e269..75a5dfca 100644 --- a/src/test/cucumber/service_unavailable.feature +++ b/src/test/cucumber/service_unavailable.feature @@ -4,7 +4,7 @@ Feature: Service Unavailable Given the internet is not reachable And an initialised environment - # list command + # list commands Scenario: List candidate versions found while Offline Given the candidate "grails" version "2.1.0" is already installed and default @@ -21,6 +21,11 @@ Feature: Service Unavailable Then I see "Offline: only showing installed grails versions" And I see "None installed!" + Scenario: List Available Candidates while Offline + Given the system is bootstrapped + When I enter "sdk list" + Then I see "This command is not available while offline." + # use command Scenario: Use the default candidate version while Offline