From b96abcfda9506e820a0d6d6b42befa1bf4971034 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Sat, 7 May 2022 11:23:33 +0800 Subject: [PATCH] feat(scoop-cleanup): Add `-a/--all` switch to cleanup all apps (#4906) --- CHANGELOG.md | 1 + libexec/scoop-cleanup.ps1 | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c0fb3891..992659c45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - **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 diff --git a/libexec/scoop-cleanup.ps1 b/libexec/scoop-cleanup.ps1 index 49be7a2e6..6ce40a211 100644 --- a/libexec/scoop-cleanup.ps1 +++ b/libexec/scoop-cleanup.ps1 @@ -3,9 +3,10 @@ # Help: 'scoop cleanup' cleans Scoop apps by removing old versions. # 'scoop cleanup ' cleans up the old versions of that app if said versions exist. # -# You can use '*' in place of to cleanup all apps. +# You can use '*' in place of or `-a`/`--all` switch to cleanup all apps. # # Options: +# -a, --all Cleanup all apps (alternative to '*') # -g, --global Cleanup a globally installed app # -k, --cache Remove outdated download cache @@ -14,12 +15,13 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$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 } $global = $opt.g -or $opt.global $cache = $opt.k -or $opt.cache +$all = $opt.a -or $opt.all -if (!$apps) { 'ERROR: missing'; my_usage; exit 1 } +if (!$apps -and !$all) { 'ERROR: missing'; my_usage; exit 1 } if ($global -and !(is_admin)) { 'ERROR: you need admin rights to cleanup global apps'; exit 1 @@ -59,8 +61,8 @@ function cleanup($app, $global, $verbose, $cache) { Write-Host '' } -if ($apps) { - if ($apps -eq '*') { +if ($apps -or $all) { + if ($apps -eq '*' -or $all) { $verbose = $false $apps = applist (installed_apps $false) $false if ($global) {