ghcurl 0.5.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +59 -11
- data/bin/ghcurl +247 -96
- data/lib/ghcurl.rb +6 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fec37deabe100d853deadbbf290658a5336a3ea0570948a0247a0f9fe6ece0c5
|
4
|
+
data.tar.gz: 48eddecd5fa148528eee00072e1270ec7a5af4d4bea22a942d84f2e27f1da3ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7d4839bcc4066350d2a8a4fb35364a6d297fc413193bd68e6366f196d60ecccedd4f1a5b8fa2ee17b4e6e653ecb75a94910f4008dbb235f96a8f4e60d890613
|
7
|
+
data.tar.gz: c0b96d5a08f55fab2d326dcc69b4703b7852c44eb61f5ce9dc30c2cba5eea357e47790e3830ec775ea11f7a38ec64faaf962aff88d092d144d7e60b8acaeda07
|
data/README.md
CHANGED
@@ -4,34 +4,79 @@
|
|
4
4
|
|
5
5
|
[](https://rubygems.org/gems/ghcurl)
|
6
6
|
|
7
|
+
|
8
|
+
Download files and install from Github releases.
|
9
|
+
|
7
10
|
```bash
|
8
11
|
gem install ghcurl
|
9
12
|
```
|
10
13
|
|
11
|
-
|
14
|
+
</div>
|
12
15
|
|
13
|
-
|
16
|
+
`ghcurl` can recognize your OS and arch, give you the proper option to download. You can search by regular expression, specify a version, and install it to a path or according to the environment variable `GHCURL_BIN_PATH` or just `/usr/local/bin`. It will automatically extract a tar/zip file to make the installation process better.
|
14
17
|
|
15
|
-
|
18
|
+
Note it doesn't work on Windows.
|
19
|
+
|
20
|
+
<br>
|
16
21
|
|
17
22
|
## Usage
|
18
23
|
|
19
|
-
Download latest deb/rpm package and install, notice the argument `deb` / `rpm` are just regular expressions.
|
20
24
|
```bash
|
21
|
-
ghcurl
|
22
|
-
ghcurl cli/cli rpm -i
|
25
|
+
$ ghcurl [user/]repo [regexp] [options]
|
23
26
|
```
|
24
27
|
|
25
|
-
|
28
|
+
**-o**
|
29
|
+
|
30
|
+
This is optional, download will default to `~/.cache/ghcurl`
|
31
|
+
1. `-o path` Download into path
|
32
|
+
2. `-o path/name` Download as path/name
|
33
|
+
|
34
|
+
**-v**
|
35
|
+
1. `-v 1.0.0` Download tag version 1.0.0
|
36
|
+
2. `-v3.1.4` This is also OK to download tag version 3.1.4
|
37
|
+
|
38
|
+
**-i**
|
39
|
+
1. `-i` Install to `/usr/local/bin` or `GHCURL_BIN_PATH`
|
40
|
+
2. `-i path` Install to path
|
41
|
+
|
42
|
+
**-r**
|
43
|
+
1. `-r name` Install the binary as name
|
44
|
+
|
45
|
+
<br>
|
46
|
+
|
47
|
+
## Example
|
48
|
+
|
49
|
+
Things can be easier. We consider these as popular binaries: https://github.com/ibraheemdev/modern-unix
|
50
|
+
|
51
|
+
Notice: `-i` means to install.
|
52
|
+
|
26
53
|
```bash
|
27
54
|
# It knows that's sharkdp/fd
|
28
55
|
ghcurl fd -i
|
56
|
+
|
57
|
+
# It's cli/cli !
|
58
|
+
ghcurl gh -i
|
59
|
+
|
60
|
+
# Much easier to install rbspy!
|
61
|
+
ghcurl rbspy -i
|
62
|
+
```
|
63
|
+
|
64
|
+
Download latest deb/rpm package and install, notice the argument `deb` / `rpm` are just regular expressions.
|
65
|
+
```bash
|
66
|
+
ghcurl cli/cli deb -i
|
67
|
+
ghcurl cli/cli rpm -i
|
29
68
|
```
|
30
69
|
|
31
70
|
Normal download
|
32
71
|
```bash
|
72
|
+
# The easiest way to download
|
73
|
+
ghcurl gh
|
74
|
+
|
75
|
+
# Download to /tmp
|
76
|
+
ghcurl gh -o /tmp
|
77
|
+
|
33
78
|
# Download latest rbspy-x86_64-unknown-linux-gnu.tar.gz to ~/.cache/ghcurl
|
34
|
-
ghcurl rbspy/rbspy x86_64.*linux
|
79
|
+
ghcurl rbspy/rbspy 'x86_64.*linux'
|
35
80
|
|
36
81
|
# Download rbspy version 0.11.1
|
37
82
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
@@ -40,13 +85,16 @@ ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
|
40
85
|
Download a binary and install it to anywhere
|
41
86
|
```bash
|
42
87
|
# Install to /usr/local/bin
|
43
|
-
ghcurl
|
88
|
+
ghcurl starship linux-gnu -i
|
44
89
|
|
45
90
|
# Install to ~/tmp/bin
|
46
|
-
ghcurl BetaPictoris/timeleft
|
91
|
+
ghcurl BetaPictoris/timeleft -i ~/tmp/bin
|
92
|
+
|
93
|
+
# Download as /tmp/github-cli and install
|
94
|
+
ghcurl gh -o /tmp/github-cli -i
|
47
95
|
|
48
96
|
# Install and rename it to, here, 'gd' in /usr/local/bin
|
49
|
-
ghcurl dlvhdr/gh-dash linux-amd64 -i gd
|
97
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
50
98
|
|
51
99
|
# or, like this
|
52
100
|
ghcurl dlvhdr/gh-dash linux-amd64 -i ~/tmp/bin/gd
|
data/bin/ghcurl
CHANGED
@@ -3,24 +3,23 @@
|
|
3
3
|
# File : ghcurl.rb
|
4
4
|
# Authors : ccmywish <ccmywish@qq.com>
|
5
5
|
# Created on : <2022-04-12>
|
6
|
-
# Last modified : <2022-04-
|
6
|
+
# Last modified : <2022-04-26>
|
7
7
|
#
|
8
8
|
# ghcurl:
|
9
9
|
#
|
10
|
-
# Download files
|
10
|
+
# Download files and install from Github releases
|
11
11
|
#
|
12
12
|
# ------------------------------------------------------
|
13
13
|
|
14
14
|
require 'ghcurl'
|
15
|
-
require 'nokogiri'
|
16
|
-
require 'open-uri'
|
17
15
|
require 'highline'
|
18
16
|
require 'cliswitch'
|
17
|
+
require 'fileutils'
|
19
18
|
|
20
19
|
module Ghcurl
|
21
20
|
|
22
21
|
WAREHOUSE = File.expand_path("~/.cache/ghcurl")
|
23
|
-
BIN_PATH = ENV['GHCURL_BIN_PATH'] || "/usr/local/bin"
|
22
|
+
BIN_PATH = ENV['GHCURL_BIN_PATH'].chomp('/') || "/usr/local/bin"
|
24
23
|
HL = HighLine.new
|
25
24
|
|
26
25
|
class Error < StandardError; end
|
@@ -36,14 +35,25 @@ module Ghcurl
|
|
36
35
|
end
|
37
36
|
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
#
|
39
|
+
# @return absolute download path
|
40
|
+
#
|
41
|
+
def curl(url, name, to)
|
42
|
+
if to == nil
|
43
|
+
to = WAREHOUSE + '/' + name
|
44
|
+
elsif test 'd', to
|
45
|
+
to = to.chomp('/') + '/' + name
|
46
|
+
elsif to.include?('/')
|
47
|
+
# noop
|
48
|
+
else
|
49
|
+
# just a rename in WAREHOUSE
|
50
|
+
to = WAREHOUSE + '/' + name
|
51
|
+
end
|
52
|
+
|
53
|
+
cmd = "curl -L #{url} --create-dirs -o #{to}"
|
45
54
|
system cmd
|
46
|
-
log "Downloaded to #{
|
55
|
+
log "Downloaded to #{to}"
|
56
|
+
return to
|
47
57
|
end
|
48
58
|
|
49
59
|
|
@@ -58,7 +68,8 @@ module Ghcurl
|
|
58
68
|
|
59
69
|
oses = [
|
60
70
|
['linux'],
|
61
|
-
['
|
71
|
+
['freebsd'],
|
72
|
+
['mac', 'apple', 'darwin'],
|
62
73
|
['windows']
|
63
74
|
]
|
64
75
|
|
@@ -115,8 +126,11 @@ module Ghcurl
|
|
115
126
|
end
|
116
127
|
|
117
128
|
|
118
|
-
def download(repo, regexp, version: nil)
|
129
|
+
def download(repo, regexp, version: nil, download_to: nil)
|
119
130
|
|
131
|
+
require 'octokit'
|
132
|
+
|
133
|
+
# adjust repo name : user/repo
|
120
134
|
if repo =~ /^https:\/\/github.com/
|
121
135
|
require 'uri'
|
122
136
|
uri = URI(repo)
|
@@ -134,27 +148,32 @@ module Ghcurl
|
|
134
148
|
end
|
135
149
|
|
136
150
|
log "checking..."
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
151
|
+
begin
|
152
|
+
unless version
|
153
|
+
doc = Octokit::Client.new.latest_release(repo)
|
154
|
+
else
|
155
|
+
doc = Octokit::Client.new.release_for_tag(repo, 'v' + version)
|
156
|
+
end
|
157
|
+
rescue Octokit::NotFound
|
158
|
+
puts "ghcurl: Not found #{repo} v#{version} !"
|
159
|
+
rescue Error => e
|
160
|
+
puts e
|
161
|
+
exit 0
|
141
162
|
end
|
142
163
|
|
143
|
-
|
144
|
-
links = doc.css("li>a[href^='/#{repo}/releases/download']")
|
164
|
+
links = doc.to_hash[:assets]
|
145
165
|
if links.empty?
|
146
|
-
puts doc.css('li a').map(&:to_s)
|
147
166
|
log <<~EOE
|
148
|
-
The search result is empty, check the args
|
167
|
+
The search result is empty, check the args!
|
149
168
|
repo: #{repo}
|
150
169
|
version: #{version ? version:'nil'}
|
151
|
-
|
170
|
+
|
171
|
+
Maybe there's no assets in this release
|
152
172
|
EOE
|
153
|
-
|
173
|
+
exit 0
|
154
174
|
end
|
155
175
|
|
156
|
-
|
157
|
-
links = links.map { _1['href'] }
|
176
|
+
links = links.map { _1[:browser_download_url] }
|
158
177
|
|
159
178
|
|
160
179
|
if regexp
|
@@ -186,97 +205,221 @@ module Ghcurl
|
|
186
205
|
end
|
187
206
|
end
|
188
207
|
|
189
|
-
url =
|
208
|
+
url = links[0].split('/')[0..-2].join('/') + '/' + link
|
190
209
|
|
191
210
|
log "Downloading #{url}"
|
192
211
|
|
193
|
-
|
194
|
-
|
195
|
-
curl(url, $downloaded)
|
212
|
+
dl_name = link.split('/').last
|
196
213
|
|
214
|
+
return curl(url, dl_name, download_to)
|
197
215
|
end
|
198
216
|
|
199
217
|
|
200
|
-
|
218
|
+
#
|
219
|
+
# This function is a little confusing
|
220
|
+
#
|
221
|
+
# target: The absolute path to a downloaded file
|
222
|
+
# name : The software name
|
223
|
+
#
|
224
|
+
def install(target, rename_as: nil, install_to: nil)
|
201
225
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
226
|
+
if target.end_with?('.deb')
|
227
|
+
log "Install the deb package"
|
228
|
+
system "sudo dpkg -i #{target}"
|
229
|
+
return
|
230
|
+
end
|
231
|
+
|
232
|
+
if target.end_with?('.rpm')
|
233
|
+
log "Install the rpm package"
|
234
|
+
system "sudo rpm -i #{target}"
|
235
|
+
return
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
if install_to.nil?
|
240
|
+
install_to = BIN_PATH
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
#
|
245
|
+
# Handle zip situation
|
246
|
+
#
|
247
|
+
zip_flag = false
|
248
|
+
|
249
|
+
if target.match?(/\.zip$/) or target.match?(/\.tar\.(\w){1,3}/)
|
250
|
+
|
251
|
+
zip_flag = true
|
252
|
+
|
253
|
+
# unzipped to dir
|
254
|
+
unzip_dir = ""
|
255
|
+
# unzipped files
|
256
|
+
files = ""
|
257
|
+
# the target unzipped file name (this includes the path prefix)
|
258
|
+
unzip_name = ""
|
259
|
+
|
260
|
+
# unzip
|
261
|
+
if target.match? /\.zip$/
|
262
|
+
log "Unzip zip file"
|
263
|
+
unzip_dir = target.chomp('.zip')
|
264
|
+
system "unzip -q #{target} -d #{unzip_dir}"
|
207
265
|
end
|
208
266
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
267
|
+
# .gz, .bz2, .xz
|
268
|
+
if target.match? /\.tar\.(\w){1,3}/
|
269
|
+
log "Unzip tar file"
|
270
|
+
unzip_dir = target.split('.')[0..-3].join('.')
|
271
|
+
FileUtils.mkdir_p(unzip_dir)
|
272
|
+
system "tar xf #{target} --directory=#{unzip_dir}"
|
273
|
+
end
|
274
|
+
|
275
|
+
|
276
|
+
#
|
277
|
+
# @return [Array] file names in the dir
|
278
|
+
#
|
279
|
+
def _iterate_dir(dir)
|
280
|
+
result = []
|
281
|
+
chd = Dir.children(dir)
|
282
|
+
chd_files = chd.select{|f| File.file? "#{dir}/#{f}"}
|
283
|
+
|
284
|
+
chd_files.each { result << "#{dir}/#{_1}"[2..] }
|
285
|
+
|
286
|
+
chd_dirs = chd.select{|d| File.directory?("#{dir}/#{d}") && ( d != '.git')}
|
287
|
+
chd_dirs.each do |d|
|
288
|
+
sub_dir = "#{dir}/#{d}"
|
289
|
+
result.concat _iterate_dir(sub_dir)
|
214
290
|
end
|
291
|
+
result
|
215
292
|
end
|
216
293
|
|
217
|
-
|
218
|
-
|
219
|
-
|
294
|
+
|
295
|
+
Dir.chdir unzip_dir do
|
296
|
+
files = _iterate_dir('.')
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
if files.size > 1
|
301
|
+
unzip_name = HL.choose do |menu|
|
302
|
+
menu.index_color = :rgb_77bbff
|
303
|
+
menu.prompt = "Which one do you want to install? "
|
304
|
+
menu.choices( *files )
|
305
|
+
end
|
220
306
|
else
|
221
|
-
|
307
|
+
unzip_name = files[0]
|
222
308
|
end
|
223
|
-
log "Install finish!"
|
224
|
-
end
|
225
309
|
|
310
|
+
end # end of zipped file handle
|
226
311
|
|
227
|
-
def install_on_nix(ware, place)
|
228
312
|
|
229
|
-
|
313
|
+
# Get software real name
|
314
|
+
if zip_flag
|
315
|
+
name = unzip_name.split('/').last
|
316
|
+
else
|
317
|
+
name = target.split('/').last
|
318
|
+
end
|
230
319
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
320
|
+
|
321
|
+
if (name.size > 10 ||
|
322
|
+
name.include?('.') ||
|
323
|
+
name.include?('-') ||
|
324
|
+
name.include?('_')) && (not rename_as)
|
325
|
+
log "Do you want to rename the '#{name}'?"
|
326
|
+
re = HL.ask "Input name, or just leave it blank to say no."
|
327
|
+
if !re.empty?
|
328
|
+
rename_as = re
|
329
|
+
end
|
235
330
|
end
|
236
331
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
332
|
+
|
333
|
+
if zip_flag
|
334
|
+
# Now:
|
335
|
+
# target is /home/xx/xx.zip
|
336
|
+
# unzip_dir is /home/xx/xx
|
337
|
+
# unzip_file is abc/cde/file (new target)
|
338
|
+
target = unzip_dir + '/' + unzip_name
|
241
339
|
end
|
242
340
|
|
341
|
+
log "Renamed as '#{rename_as}'" if rename_as
|
243
342
|
|
244
|
-
if test 'd', place
|
245
|
-
cmd = "sudo install -Dt #{place} -m 755 #{target} "
|
246
|
-
system cmd
|
247
|
-
log "Install #{ware} to " + place
|
248
343
|
|
344
|
+
case RUBY_PLATFORM
|
345
|
+
when /ucrt/i, /mingw/i
|
346
|
+
install_on_windows(target, name, install_to, rename_as)
|
249
347
|
else
|
250
|
-
|
251
|
-
|
252
|
-
|
348
|
+
install_on_nix(target, name, install_to, rename_as)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
|
353
|
+
#
|
354
|
+
# @param target [String] the absulute path of to be installed software
|
355
|
+
# @param name [String] the name of the software
|
356
|
+
#
|
357
|
+
def install_on_nix(target, name, install_to, rename_as)
|
358
|
+
install_to = install_to.chomp('/')
|
359
|
+
|
360
|
+
if test 'd', install_to
|
361
|
+
log "Ready to install #{name}"
|
362
|
+
if rename_as
|
363
|
+
dest = "#{install_to}/#{rename_as}"
|
364
|
+
system "sudo cp #{target} " + dest
|
365
|
+
system "sudo chmod +x " + dest
|
366
|
+
log "Installed as " + dest
|
253
367
|
else
|
254
|
-
|
368
|
+
cmd = "sudo install -Dt #{install_to} -m 755 #{target} "
|
369
|
+
system cmd
|
370
|
+
log "Install #{name} to " + install_to
|
255
371
|
end
|
256
|
-
log "
|
257
|
-
|
258
|
-
|
372
|
+
log "Install finish!"
|
373
|
+
else
|
374
|
+
log "#{install_to} is not a directory!"
|
259
375
|
end
|
260
376
|
|
261
377
|
end
|
262
378
|
|
263
379
|
|
264
|
-
def install_on_windows
|
265
|
-
log "Sorry, not implemented yet!"
|
380
|
+
def install_on_windows(target, name, install_to, rename_as)
|
381
|
+
log "Sorry, not implemented yet on Windows! Can you help?"
|
266
382
|
end
|
267
383
|
|
268
384
|
|
385
|
+
#
|
386
|
+
# For -l option
|
387
|
+
#
|
269
388
|
def list_wares
|
270
|
-
|
271
|
-
puts blue("
|
272
|
-
puts
|
389
|
+
FileUtils.mkdir_p(WAREHOUSE)
|
390
|
+
puts blue("ghcurl: #{WAREHOUSE}")
|
273
391
|
Dir.children(WAREHOUSE).each_with_index do |dict,i|
|
274
|
-
puts "
|
392
|
+
puts "#{blue(i+1)}. #{bold(green(dict))}"
|
275
393
|
end
|
276
|
-
puts
|
277
394
|
end
|
278
395
|
|
279
396
|
|
397
|
+
#
|
398
|
+
# For -d option
|
399
|
+
#
|
400
|
+
def delete_wares(name)
|
401
|
+
begin
|
402
|
+
|
403
|
+
if name.nil?
|
404
|
+
re = HL.ask "Do you want to delete all downloaded files?[Enter to yes or n]"
|
405
|
+
case re.downcase
|
406
|
+
when '','y','ye','yes','true'
|
407
|
+
FileUtils.rm_rf WAREHOUSE
|
408
|
+
log "Delete all done"
|
409
|
+
end
|
410
|
+
else
|
411
|
+
FileUtils.rm WAREHOUSE + '/' + name
|
412
|
+
log "Delete #{name} done"
|
413
|
+
end
|
414
|
+
|
415
|
+
rescue Exception => e
|
416
|
+
puts bold(red("ghcurl: #{e}"))
|
417
|
+
list_wares
|
418
|
+
end
|
419
|
+
|
420
|
+
end # end def delete_wares
|
421
|
+
|
422
|
+
|
280
423
|
def help
|
281
424
|
puts <<~EOC
|
282
425
|
ghcurl (v#{VERSION}): Download files and install from Github releases
|
@@ -284,18 +427,21 @@ module Ghcurl
|
|
284
427
|
Default install to env 'GHCURL_BIN_PATH' or /usr/local/bin
|
285
428
|
|
286
429
|
usage:
|
287
|
-
ghcurl [user]/repo [regexp]
|
288
|
-
ghcurl repo [re] -v tag
|
289
|
-
ghcurl repo [
|
290
|
-
ghcurl repo [re] -i [path]
|
291
|
-
ghcurl repo [re] -i
|
292
|
-
ghcurl -
|
293
|
-
ghcurl -
|
430
|
+
ghcurl [user]/repo [regexp] => Search latest version with regexp to download
|
431
|
+
ghcurl repo [re] -v tag => Download a specific tag version
|
432
|
+
ghcurl repo [re] -o [path] => Download into path or rename
|
433
|
+
ghcurl repo [re] -i [path] => Download and install to path
|
434
|
+
ghcurl repo [re] -o [path] -i => Download into path and install
|
435
|
+
ghcurl repo [re] -i -r name => Download and install as 'name'
|
436
|
+
ghcurl -l => List downloaded files
|
437
|
+
ghcurl -d [name] => Delete a downloaded file or all
|
438
|
+
ghcurl -h => Print this help
|
294
439
|
|
295
440
|
example:
|
296
441
|
ghcurl bat => Search sharkdp/bat the latest
|
297
442
|
ghcurl cli deb -i => Search cli/cli /deb/
|
298
443
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
444
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
299
445
|
|
300
446
|
EOC
|
301
447
|
end
|
@@ -311,9 +457,12 @@ extend Ghcurl
|
|
311
457
|
|
312
458
|
class Ghcurl::CLI < CliSwitch
|
313
459
|
option name: 'install', short: '-i', arg_required: 'optional'
|
460
|
+
option name: 'output', short: '-o', long: '--output', arg_required: 'required'
|
461
|
+
option name: 'rename', short: '-r', arg_required: 'required'
|
314
462
|
option name: 'version', short: '-v', arg_required: 'required'
|
315
|
-
option name: 'help',
|
316
|
-
option name: 'list',
|
463
|
+
option name: 'help', short: '-h', long: '--help', arg_required: 'noarg'
|
464
|
+
option name: 'list', short: '-l', arg_required: 'noarg'
|
465
|
+
option name: 'delete', short: '-d', arg_required: 'optional'
|
317
466
|
end
|
318
467
|
|
319
468
|
args, opts = Ghcurl::CLI.new.parse(ARGV)
|
@@ -323,16 +472,13 @@ if args.empty? and opts.empty?
|
|
323
472
|
exit
|
324
473
|
end
|
325
474
|
|
326
|
-
if args.size >= 2
|
327
|
-
repo_or_name, regexp = args[0], args[1]
|
328
|
-
else
|
329
|
-
repo_or_name, regexp = args[0], nil
|
330
|
-
end
|
331
|
-
|
332
475
|
|
476
|
+
repo_or_name, regexp = args[0], args[1]
|
333
477
|
version = nil
|
334
478
|
need_install = false
|
479
|
+
download_to = nil
|
335
480
|
install_to = nil
|
481
|
+
rename_as = nil
|
336
482
|
|
337
483
|
opts.each do
|
338
484
|
case _1.name
|
@@ -342,11 +488,18 @@ opts.each do
|
|
342
488
|
when 'list'
|
343
489
|
list_wares
|
344
490
|
exit
|
491
|
+
when 'delete'
|
492
|
+
delete_wares(_1.next_arg)
|
493
|
+
exit
|
345
494
|
when 'version'
|
346
495
|
version = _1.next_arg
|
496
|
+
when 'output'
|
497
|
+
download_to = _1.next_arg
|
347
498
|
when 'install'
|
348
499
|
need_install = true
|
349
500
|
install_to = _1.next_arg
|
501
|
+
when 'rename'
|
502
|
+
rename_as = _1.next_arg
|
350
503
|
end
|
351
504
|
end
|
352
505
|
|
@@ -354,16 +507,14 @@ end
|
|
354
507
|
# p repo_or_name
|
355
508
|
# p regexp
|
356
509
|
# p need_install
|
510
|
+
# p download_to
|
357
511
|
# p install_to
|
512
|
+
# p rename_as
|
358
513
|
|
359
514
|
begin
|
360
|
-
download(repo_or_name, regexp, version: version)
|
515
|
+
ware = download(repo_or_name, regexp, version: version, download_to: download_to)
|
361
516
|
if need_install
|
362
|
-
|
363
|
-
install(repo_or_name, place: install_to)
|
364
|
-
else
|
365
|
-
install(repo_or_name)
|
366
|
-
end
|
517
|
+
install(ware, rename_as: rename_as, install_to: install_to)
|
367
518
|
end
|
368
519
|
rescue Interrupt
|
369
520
|
end
|
data/lib/ghcurl.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# File : ghcurl.rb
|
3
3
|
# Authors : ccmywish <ccmywish@qq.com>
|
4
4
|
# Created on : <2022-04-12>
|
5
|
-
# Last modified : <2022-04-
|
5
|
+
# Last modified : <2022-04-26>
|
6
6
|
#
|
7
7
|
# ghcurl:
|
8
8
|
#
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
module Ghcurl
|
14
14
|
|
15
|
-
VERSION = "0.
|
15
|
+
VERSION = "0.7.1"
|
16
16
|
|
17
17
|
end
|
18
18
|
|
@@ -24,6 +24,7 @@ end
|
|
24
24
|
Ghcurl::DEFAULT_WARES = {
|
25
25
|
|
26
26
|
cli: 'cli/cli',
|
27
|
+
gh: 'cli/cli',
|
27
28
|
|
28
29
|
fd: 'sharkdp/fd',
|
29
30
|
bat: 'sharkdp/bat',
|
@@ -61,5 +62,7 @@ Ghcurl::DEFAULT_WARES = {
|
|
61
62
|
xh: 'ducaale/xh',
|
62
63
|
zoxide: 'ajeetdsouza/zoxide',
|
63
64
|
|
64
|
-
scc:
|
65
|
+
scc: 'boyter/scc',
|
66
|
+
rbspy: 'rbspy/rbspy',
|
67
|
+
starship: 'starship/starship'
|
65
68
|
}
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghcurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ccmywish
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: octokit
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.22'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.22'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: highline
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|