diff --git a/.gitignore b/.gitignore index ca4c791a..7a7853ac 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ mongo.json out/ sdkman-cli.iml target/ +bin/ diff --git a/src/main/bash/sdkman-flush.sh b/src/main/bash/sdkman-flush.sh index 94642c04..7dba36a0 100644 --- a/src/main/bash/sdkman-flush.sh +++ b/src/main/bash/sdkman-flush.sh @@ -21,13 +21,7 @@ function __sdk_flush { case "$qualifier" in broadcast) - if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then - rm "${SDKMAN_DIR}/var/broadcast_id" - rm "${SDKMAN_DIR}/var/broadcast" - __sdkman_echo_green "Broadcast has been flushed." - else - __sdkman_echo_no_colour "No prior broadcast found so not flushed." - fi + __sdkman_cleanup_broadcast ;; version) if [[ -f "${SDKMAN_DIR}/var/version" ]]; then @@ -45,7 +39,8 @@ function __sdk_flush { __sdkman_cleanup_folder "tmp" ;; *) - __sdkman_echo_red "Stop! Please specify what you want to flush." + __sdkman_cleanup_folder "archives" + __sdkman_cleanup_folder "tmp" ;; esac } @@ -60,4 +55,14 @@ function __sdkman_cleanup_folder { mkdir "${SDKMAN_DIR}/${folder}" __sdkman_echo_green "${sdkman_cleanup_count} archive(s) flushed, freeing ${sdkman_cleanup_disk_usage}." +} + +function __sdkman_cleanup_broadcast { + if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then + rm "${SDKMAN_DIR}/var/broadcast_id" + rm "${SDKMAN_DIR}/var/broadcast" + __sdkman_echo_green "Broadcast has been flushed." + else + __sdkman_echo_no_colour "No prior broadcast found so not flushed." + fi } \ No newline at end of file diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index f5e56dc7..9adc6816 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -35,7 +35,7 @@ function __sdk_help { __sdkman_echo_no_colour " offline [enable|disable]" __sdkman_echo_no_colour " selfupdate [force]" __sdkman_echo_no_colour " update" - __sdkman_echo_no_colour " flush " + __sdkman_echo_no_colour " flush [archives|temp|broadcast|version]" __sdkman_echo_no_colour "" __sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc." __sdkman_echo_no_colour " use list command for comprehensive list of candidates" diff --git a/src/test/cucumber/flush.feature b/src/test/cucumber/flush.feature index 8fc0c74b..b6fe0ad2 100644 --- a/src/test/cucumber/flush.feature +++ b/src/test/cucumber/flush.feature @@ -4,10 +4,15 @@ Feature: Flush Given the internet is reachable And an initialised environment And the system is bootstrapped - - Scenario: Flush omitting the Qualifier + + Scenario: Clear out the cached archives and the temporary storage + Given the archive "grails-1.3.9.zip" has been cached + And the file "res-1.2.0.zip" in temporary storage When I enter "sdk flush" - Then I see "Stop! Please specify what you want to flush." + Then no archives are cached + And no "res-1.2.0.zip" file is present in temporary storage + And I see "1 archive(s) flushed" + And I see "1 archive(s) flushed" Scenario: Clean up the current Broadcast Given a prior Broadcast "This is an old broadcast" with id "12344" was issued @@ -32,7 +37,7 @@ Feature: Flush Then no archives are cached And I see "1 archive(s) flushed" - Scenario: Clear out the temporary space + Scenario: Clear out the temporary storage Given the file "res-1.2.0.zip" in temporary storage When I enter "sdk flush temp" Then no "res-1.2.0.zip" file is present in temporary storage