feat(scoop-cleanup): Add -a/--all switch to cleanup all apps (#4906)

This commit is contained in:
Hsiao-nan Cheung
2022-05-07 11:23:33 +08:00
committed by GitHub
parent cb7cd99e7a
commit b96abcfda9
2 changed files with 8 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
### Features ### Features
- **install:** Allow downloading from private repositories ([#4254](https://github.com/ScoopInstaller/Scoop/issues/4254)) - **install:** Allow downloading from private repositories ([#4254](https://github.com/ScoopInstaller/Scoop/issues/4254))
- **scoop-cleanup:** Add `-a/--all` switch to cleanup all apps ([#4906](https://github.com/ScoopInstaller/Scoop/issues/4906))
### Bug Fixes ### Bug Fixes

View File

@@ -3,9 +3,10 @@
# Help: 'scoop cleanup' cleans Scoop apps by removing old versions. # Help: 'scoop cleanup' cleans Scoop apps by removing old versions.
# 'scoop cleanup <app>' cleans up the old versions of that app if said versions exist. # 'scoop cleanup <app>' cleans up the old versions of that app if said versions exist.
# #
# You can use '*' in place of <app> to cleanup all apps. # You can use '*' in place of <app> or `-a`/`--all` switch to cleanup all apps.
# #
# Options: # Options:
# -a, --all Cleanup all apps (alternative to '*')
# -g, --global Cleanup a globally installed app # -g, --global Cleanup a globally installed app
# -k, --cache Remove outdated download cache # -k, --cache Remove outdated download cache
@@ -14,12 +15,13 @@
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
. "$PSScriptRoot\..\lib\install.ps1" # persist related . "$PSScriptRoot\..\lib\install.ps1" # persist related
$opt, $apps, $err = getopt $args 'gk' 'global', 'cache' $opt, $apps, $err = getopt $args 'agk' 'all', 'global', 'cache'
if ($err) { "scoop cleanup: $err"; exit 1 } if ($err) { "scoop cleanup: $err"; exit 1 }
$global = $opt.g -or $opt.global $global = $opt.g -or $opt.global
$cache = $opt.k -or $opt.cache $cache = $opt.k -or $opt.cache
$all = $opt.a -or $opt.all
if (!$apps) { 'ERROR: <app> missing'; my_usage; exit 1 } if (!$apps -and !$all) { 'ERROR: <app> missing'; my_usage; exit 1 }
if ($global -and !(is_admin)) { if ($global -and !(is_admin)) {
'ERROR: you need admin rights to cleanup global apps'; exit 1 'ERROR: you need admin rights to cleanup global apps'; exit 1
@@ -59,8 +61,8 @@ function cleanup($app, $global, $verbose, $cache) {
Write-Host '' Write-Host ''
} }
if ($apps) { if ($apps -or $all) {
if ($apps -eq '*') { if ($apps -eq '*' -or $all) {
$verbose = $false $verbose = $false
$apps = applist (installed_apps $false) $false $apps = applist (installed_apps $false) $false
if ($global) { if ($global) {