Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions libexec/scoop-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# 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.
#
# 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:
# -a, --all Cleanup all apps (alternative to '*')
# -g, --global Cleanup a globally installed app
# -k, --cache Remove outdated download cache

Expand All @@ -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: <app> missing'; my_usage; exit 1 }
if (!$apps -and !$all) { 'ERROR: <app> missing'; my_usage; exit 1 }

if ($global -and !(is_admin)) {
'ERROR: you need admin rights to cleanup global apps'; exit 1
Expand Down Expand Up @@ -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) {
Expand Down