From 9811a5f8536d01e8faba9b8cb36da333c10a9dc7 Mon Sep 17 00:00:00 2001 From: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:47:31 +0530 Subject: [PATCH] feat(chore): Add missing -a/--all param to all commands (#5004) * feat(scoop-reset): Add -a/--all switch to reset all apps * feat(scoop-cache): Add -a/--all switch to delete whole cache * feat(scoop-virustotal): Add -e/--every switch to check every installed app * Update CHANGELOG.md * use 'all' instead of 'every' --- CHANGELOG.md | 1 + libexec/scoop-cache.ps1 | 4 +++- libexec/scoop-reset.ps1 | 9 ++++++--- libexec/scoop-virustotal.ps1 | 10 +++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 293e5bb5f6..b8f59d4732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features +- **chore:** Add missing -a/--all param to all commands ([#5004](https://github.com/ScoopInstaller/Scoop/issues/5004)) - **scoop-status:** Check bucket status, improve output ([#5011](https://github.com/ScoopInstaller/Scoop/issues/5011)) - **scoop-info:** Show app installed/download size ([#4886](https://github.com/ScoopInstaller/Scoop/issues/4886)) diff --git a/libexec/scoop-cache.ps1 b/libexec/scoop-cache.ps1 index 96cd23763c..959c73fcde 100644 --- a/libexec/scoop-cache.ps1 +++ b/libexec/scoop-cache.ps1 @@ -10,6 +10,8 @@ # # To clear everything in your cache, use: # scoop cache rm * +# You can also use the `-a/--all` switch in place of `*` here + param($cmd) function cacheinfo($file) { @@ -36,7 +38,7 @@ function cacheremove($app) { 'ERROR: missing' my_usage exit 1 - } elseif ($app -eq '*') { + } elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') { $files = @(Get-ChildItem $cachedir) } else { $app = '(' + ($app -join '|') + ')' diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index 05cefe47cc..f84328bcbe 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -3,6 +3,8 @@ # Help: Used to resolve conflicts in favor of a particular app. For example, # if you've installed 'python' and 'python27', you can use 'scoop reset' to switch between # using one or the other. +# +# You can use '*' in place of or `-a`/`--all` switch to reset all apps. . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly) @@ -10,12 +12,13 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\shortcuts.ps1" -$opt, $apps, $err = getopt $args +$opt, $apps, $err = getopt $args 'a' 'all' if($err) { "scoop reset: $err"; exit 1 } +$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($apps -eq '*') { +if($apps -eq '*' -or $all) { $local = installed_apps $false | ForEach-Object { ,@($_, $false) } $global = installed_apps $true | ForEach-Object { ,@($_, $true) } $apps = @($local) + @($global) diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 37da80ce52..ef4b84e2f6 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -2,7 +2,7 @@ # Summary: Look for app's hash or url on virustotal.com # Help: Look for app's hash or url on virustotal.com # -# Use a single '*' for app to check all installed apps. +# Use a single '*' or the '-a/--all' switch to check all installed apps. # # To use this command, you have to sign up to VirusTotal's community, # and get an API key. Then, tell scoop about your API key with: @@ -20,7 +20,7 @@ # 2 & 4 combined # # Options: -# -a, --arch <32bit|64bit> Use the specified architecture, if the app supports it +# -a, --all Check for all installed apps # -s, --scan For packages where VirusTotal has no information, send download URL # for analysis (and future retrieval). This requires you to configure # your virustotal_api_key. @@ -34,10 +34,10 @@ . "$PSScriptRoot\..\lib\install.ps1" # 'hash_for_url' . "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency' -$opt, $apps, $err = getopt $args 'a:snup' @('arch=', 'scan', 'no-depends', 'no-update-scoop', 'passthru') +$opt, $apps, $err = getopt $args 'asnup' @('all', 'scan', 'no-depends', 'no-update-scoop', 'passthru') if ($err) { "scoop virustotal: $err"; exit 1 } if (!$apps) { my_usage; exit 1 } -$architecture = ensure_architecture ($opt.a + $opt.arch) +$architecture = ensure_architecture if (is_scoop_outdated) { if ($opt.u -or $opt.'no-update-scoop') { @@ -49,7 +49,7 @@ if (is_scoop_outdated) { $apps_param = $apps -if ($apps_param -eq '*') { +if ($apps_param -eq '*' -or $opt.a -or $opt.all) { $apps = installed_apps $false $apps += installed_apps $true }