@@ -57,6 +57,55 @@ function find_manifest($app, $bucket) {
5757 }
5858}
5959
60+ function add_bucket ($name , $repo ) {
61+ if (! $name ) { " <name> missing" ; $usage_add ; exit 1 }
62+ if (! $repo ) {
63+ $repo = known_bucket_repo $name
64+ if (! $repo ) { " Unknown bucket '$name '. Try specifying <repo>." ; $usage_add ; exit 1 }
65+ }
66+
67+ $git = try { Get-Command ' git' - ea stop } catch { $null }
68+ if (! $git ) {
69+ abort " Git is required for buckets. Run 'scoop install git'."
70+ }
71+
72+ $dir = bucketdir $name
73+ if (test-path $dir ) {
74+ warn " The '$name ' bucket already exists. Use 'scoop bucket rm $name ' to remove it."
75+ exit 0
76+ }
77+
78+ write-host ' Checking repo... ' - nonewline
79+ $out = git_ls_remote $repo 2>&1
80+ if ($lastexitcode -ne 0 ) {
81+ abort " '$repo ' doesn't look like a valid git repository`n`n Error given:`n $out "
82+ }
83+ write-host ' ok'
84+
85+ ensure $bucketsdir > $null
86+ $dir = ensure $dir
87+ git_clone " $repo " " `" $dir `" " - q
88+ success " The $name bucket was added successfully."
89+ }
90+
91+ function rm_bucket ($name ) {
92+ if (! $name ) { " <name> missing" ; $usage_rm ; exit 1 }
93+ $dir = bucketdir $name
94+ if (! (test-path $dir )) {
95+ abort " '$name ' bucket not found."
96+ }
97+
98+ Remove-Item $dir - r - force - ea stop
99+ }
100+
101+ function list_buckets {
102+ buckets
103+ }
104+
105+ function known_buckets {
106+ known_bucket_repos | ForEach-Object { $_.psobject.properties | Select-Object - expand ' name' }
107+ }
108+
60109function new_issue_msg ($app , $bucket , $title , $body ) {
61110 $app , $manifest , $bucket , $url = locate $app $bucket
62111 $url = known_bucket_repo $bucket
0 commit comments