Skip to content

Commit 9f2d9de

Browse files
committed
Merge branch 'delight-feature/flush_all' into master
2 parents bdafe06 + ab97b73 commit 9f2d9de

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/main/bash/sdkman-flush.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ function __sdk_flush() {
2121

2222
case "$qualifier" in
2323
broadcast)
24-
if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then
25-
rm "${SDKMAN_DIR}/var/broadcast_id"
26-
rm "${SDKMAN_DIR}/var/broadcast"
27-
__sdkman_echo_green "Broadcast has been flushed."
28-
else
29-
__sdkman_echo_no_colour "No prior broadcast found so not flushed."
30-
fi
24+
__sdkman_cleanup_broadcast
3125
;;
3226
version)
3327
if [[ -f "${SDKMAN_DIR}/var/version" ]]; then
@@ -45,7 +39,8 @@ function __sdk_flush() {
4539
__sdkman_cleanup_folder "tmp"
4640
;;
4741
*)
48-
__sdkman_echo_red "Stop! Please specify what you want to flush."
42+
__sdkman_cleanup_folder "archives"
43+
__sdkman_cleanup_folder "tmp"
4944
;;
5045
esac
5146
}
@@ -61,3 +56,14 @@ function __sdkman_cleanup_folder() {
6156

6257
__sdkman_echo_green "${sdkman_cleanup_count} archive(s) flushed, freeing ${sdkman_cleanup_disk_usage}."
6358
}
59+
60+
function __sdkman_cleanup_broadcast {
61+
if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then
62+
rm "${SDKMAN_DIR}/var/broadcast_id"
63+
rm "${SDKMAN_DIR}/var/broadcast"
64+
__sdkman_echo_green "Broadcast has been flushed."
65+
else
66+
__sdkman_echo_no_colour "No prior broadcast found so not flushed."
67+
fi
68+
}
69+

src/main/bash/sdkman-help.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function __sdk_help() {
3737
__sdkman_echo_no_colour " offline [enable|disable]"
3838
__sdkman_echo_no_colour " selfupdate [force]"
3939
__sdkman_echo_no_colour " update"
40-
__sdkman_echo_no_colour " flush <broadcast|archives|temp>"
40+
__sdkman_echo_no_colour " flush [archives|temp|broadcast|version]"
4141
__sdkman_echo_no_colour ""
4242
__sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc."
4343
__sdkman_echo_no_colour " use list command for comprehensive list of candidates"

src/test/resources/features/flush.feature

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ Feature: Flush
44
Given the internet is reachable
55
And an initialised environment
66
And the system is bootstrapped
7-
8-
Scenario: Flush omitting the Qualifier
7+
8+
Scenario: Clear out the cached archives and the temporary storage
9+
Given the archive "grails-1.3.9.zip" has been cached
10+
And the file "res-1.2.0.zip" in temporary storage
911
When I enter "sdk flush"
10-
Then I see "Stop! Please specify what you want to flush."
12+
Then no archives are cached
13+
And no "res-1.2.0.zip" file is present in temporary storage
14+
And I see "1 archive(s) flushed"
15+
And I see "1 archive(s) flushed"
1116

1217
Scenario: Clean up the current Broadcast
1318
Given a prior Broadcast "This is an old broadcast" with id "12344" was issued
@@ -32,7 +37,7 @@ Feature: Flush
3237
Then no archives are cached
3338
And I see "1 archive(s) flushed"
3439

35-
Scenario: Clear out the temporary space
40+
Scenario: Clear out the temporary storage
3641
Given the file "res-1.2.0.zip" in temporary storage
3742
When I enter "sdk flush temp"
3843
Then no "res-1.2.0.zip" file is present in temporary storage

0 commit comments

Comments
 (0)