From 4cf833364f9696fc04336c330b04cd1f27003591 Mon Sep 17 00:00:00 2001 From: wangzq Date: Fri, 3 Jun 2016 11:13:28 +0800 Subject: [PATCH 1/3] Add a new subcommand "list-known" to command "bucket" --- lib/buckets.ps1 | 16 ++++++++++------ libexec/scoop-bucket.ps1 | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 589be6e45..86c8b60b5 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -21,12 +21,16 @@ function apps_in_bucket($dir) { gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' } } -function buckets { - $buckets = @() - if(test-path $bucketsdir) { - gci $bucketsdir | % { $buckets += $_.name } - } - $buckets +function buckets([switch]$known) { + if ($known) { + known_bucket_repos | Get-Member | ? { $_.MemberType -eq 'NoteProperty' } | Select -Expand Name + } else { + $buckets = @() + if(test-path $bucketsdir) { + gci $bucketsdir | % { $buckets += $_.name } + } + $buckets + } } function find_manifest($app, $bucket) { diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index e87c60bac..c6b3b2079 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -14,6 +14,9 @@ # # Since the 'extras' bucket is known to Scoop, this can be shortened to: # scoop bucket add extras +# +# To list all known buckets, use: +# scoop bucket list-known param($cmd, $name, $repo) . "$psscriptroot\..\lib\core.ps1" @@ -77,5 +80,6 @@ switch($cmd) { "add" { add_bucket $name $repo } "rm" { rm_bucket $name } "list" { list_buckets } + "list-known" { buckets -known } default { "scoop bucket: cmd '$cmd' not supported"; my_usage; exit 1 } } From abbc571b623e748a11ad3806f1ada52c9092139f Mon Sep 17 00:00:00 2001 From: wangzq Date: Fri, 3 Jun 2016 11:17:40 +0800 Subject: [PATCH 2/3] Update usage --- libexec/scoop-bucket.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index c6b3b2079..06506a318 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -1,4 +1,4 @@ -# Usage: scoop bucket add|list|rm [] +# Usage: scoop bucket add|list|list-known|rm [] # Summary: Manage Scoop buckets # Help: Add, list or remove buckets. # From fad7fd5a251ba57ac10146bc53827a412c0d5ef6 Mon Sep 17 00:00:00 2001 From: Luke Sampson Date: Fri, 3 Jun 2016 14:14:35 +1000 Subject: [PATCH 3/3] fixes to #888 to match conventions --- lib/buckets.ps1 | 16 ++++++---------- libexec/scoop-bucket.ps1 | 10 +++++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 86c8b60b5..589be6e45 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -21,16 +21,12 @@ function apps_in_bucket($dir) { gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' } } -function buckets([switch]$known) { - if ($known) { - known_bucket_repos | Get-Member | ? { $_.MemberType -eq 'NoteProperty' } | Select -Expand Name - } else { - $buckets = @() - if(test-path $bucketsdir) { - gci $bucketsdir | % { $buckets += $_.name } - } - $buckets - } +function buckets { + $buckets = @() + if(test-path $bucketsdir) { + gci $bucketsdir | % { $buckets += $_.name } + } + $buckets } function find_manifest($app, $bucket) { diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index b5cc7eaf7..f6e968de5 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -1,4 +1,4 @@ -# Usage: scoop bucket add|list|list-known|rm [] +# Usage: scoop bucket add|list|known|rm [] # Summary: Manage Scoop buckets # Help: Add, list or remove buckets. # @@ -16,7 +16,7 @@ # scoop bucket add extras # # To list all known buckets, use: -# scoop bucket list-known +# scoop bucket known param($cmd, $name, $repo) . "$psscriptroot\..\lib\core.ps1" @@ -73,10 +73,14 @@ function list_buckets { buckets } +function known_buckets { + known_bucket_repos |% { $_.psobject.properties | select -expand 'name' } +} + switch($cmd) { "add" { add_bucket $name $repo } "rm" { rm_bucket $name } "list" { list_buckets } - "list-known" { buckets -known } + "known" { known_buckets } default { "scoop bucket: cmd '$cmd' not supported"; my_usage; exit 1 } }