Skip to content

Commit 465d7bc

Browse files
committed
Add fvm cache dir|clean commands
1 parent 0d0ab3e commit 465d7bc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

fvm.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ fvm() {
409409
fvm_echo ' The following optional arguments:'
410410
fvm_echo ' -g,--global Unset global default flutter <version>.'
411411
fvm_echo ' fvm unload Unload `fvm` from shell'
412+
fvm_echo ' fvm cache dir Display path to the cache directory for fvm'
413+
fvm_echo ' fvm cache clear Empty cache directory for fvm'
412414
fvm_echo 'Example:'
413415
fvm_echo ' fvm install 3.0.0 Install the 3.0.0 version of flutter'
414416
fvm_echo ' fvm use 2.0.0 Use 2.0.0 version of flutter'
@@ -429,6 +431,25 @@ fvm() {
429431
local VERSION
430432

431433
case $COMMAND in
434+
"cache")
435+
case "${1-}" in
436+
dir) fvm_cache_dir ;;
437+
clear)
438+
local DIR
439+
DIR="$(fvm_cache_dir)"
440+
if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
441+
fvm_echo 'fvm cache cleared.'
442+
else
443+
fvm_err "Unable to clear fvm cache: ${DIR}"
444+
return 1
445+
fi
446+
;;
447+
*)
448+
>&2 fvm --help
449+
return 127
450+
;;
451+
esac
452+
;;
432453
"install" | "i")
433454

434455
if ! fvm_has "curl" && ! fvm_has "wget"; then

0 commit comments

Comments
 (0)