Skip to content

Commit

Permalink
feat(chore): Add missing -a/--all param to all commands (ScoopInstall…
Browse files Browse the repository at this point in the history
…er#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'
  • Loading branch information
rashil2000 authored Jun 22, 2022
1 parent 6629331 commit 9811a5f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 3 additions & 1 deletion libexec/scoop-cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -36,7 +38,7 @@ function cacheremove($app) {
'ERROR: <app(s)> 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 '|') + ')'
Expand Down
9 changes: 6 additions & 3 deletions libexec/scoop-reset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
# 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 <app> or `-a`/`--all` switch to reset all apps.

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\install.ps1"
. "$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 '<app> missing'; my_usage; exit 1 }
if(!$apps -and !$all) { error '<app> 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)
Expand Down
10 changes: 5 additions & 5 deletions libexec/scoop-virustotal.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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') {
Expand All @@ -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
}
Expand Down

0 comments on commit 9811a5f

Please sign in to comment.