Convenience method "sdk flush"

- flush -> flush archives and flush temp
- adds "bin/" to .gitignore
This commit is contained in:
Konstantinos Kostarellis
2020-02-07 20:38:26 +01:00
parent 28f4190406
commit 2e4eb63b9b
4 changed files with 24 additions and 13 deletions

1
.gitignore vendored
View File

@@ -18,3 +18,4 @@ mongo.json
out/
sdkman-cli.iml
target/
bin/

View File

@@ -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
}

View File

@@ -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 <broadcast|archives|temp>"
__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"

View File

@@ -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