ghcurl 0.5.0 → 0.7.0
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 +61 -7
- data/bin/ghcurl +251 -101
- data/lib/ghcurl.rb +6 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efa8ec89c9537aeb042258adb82a8b4c5b5906fee9f75d1ac348bb59d98095a7
|
4
|
+
data.tar.gz: a95f9e3385e1bb9766c1b807520ae191f768801e83fffe29a7231a10f4926cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1839ed2a13c403b71a7ea01773f7ec9b4b7b13b3a7f2aade2fa567703e46fb3b8b2b05395f17fa690924d93a8c570195b57d733768883f07b6f44aab58c5fb3
|
7
|
+
data.tar.gz: b37c28392213b7b0a73343b8fa61399d510edc3ff8fc51758e95e79c10bf30f7188851d3e5df53411b3275bee72980f5f6acf66aa69a3b4a8e57f5c3c6f8bd6b
|
data/README.md
CHANGED
@@ -4,18 +4,63 @@
|
|
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
|
|
24
|
+
```bash
|
25
|
+
$ ghcurl [user/]repo [regexp] [options]
|
26
|
+
```
|
27
|
+
|
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
|
+
|
53
|
+
```bash
|
54
|
+
# It knows that's sharkdp/fd
|
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
|
+
|
19
64
|
Download latest deb/rpm package and install, notice the argument `deb` / `rpm` are just regular expressions.
|
20
65
|
```bash
|
21
66
|
ghcurl cli/cli deb -i
|
@@ -24,8 +69,14 @@ ghcurl cli/cli rpm -i
|
|
24
69
|
|
25
70
|
Normal download
|
26
71
|
```bash
|
72
|
+
# The easiest way to download
|
73
|
+
ghcurl gh
|
74
|
+
|
75
|
+
# Download to /tmp
|
76
|
+
ghcurl gh -o /tmp
|
77
|
+
|
27
78
|
# Download latest rbspy-x86_64-unknown-linux-gnu.tar.gz to ~/.cache/ghcurl
|
28
|
-
ghcurl rbspy/rbspy x86_64.*linux
|
79
|
+
ghcurl rbspy/rbspy 'x86_64.*linux'
|
29
80
|
|
30
81
|
# Download rbspy version 0.11.1
|
31
82
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
@@ -34,13 +85,16 @@ ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
|
34
85
|
Download a binary and install it to anywhere
|
35
86
|
```bash
|
36
87
|
# Install to /usr/local/bin
|
37
|
-
ghcurl
|
88
|
+
ghcurl starship linux-gnu -i
|
38
89
|
|
39
90
|
# Install to ~/tmp/bin
|
40
|
-
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
|
41
95
|
|
42
96
|
# Install and rename it to, here, 'gd' in /usr/local/bin
|
43
|
-
ghcurl dlvhdr/gh-dash linux-amd64 -i gd
|
97
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
44
98
|
|
45
99
|
# or, like this
|
46
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,220 @@ 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
|
-
|
224
|
-
|
309
|
+
|
310
|
+
end # end of zipped file handle
|
225
311
|
|
226
312
|
|
227
|
-
|
313
|
+
# Get software real name
|
314
|
+
if zip_flag
|
315
|
+
name = unzip_name.split('/').last
|
316
|
+
else
|
317
|
+
name = target.split('/').last
|
318
|
+
end
|
228
319
|
|
229
|
-
target = "#{WAREHOUSE}/#{ware}"
|
230
320
|
|
231
|
-
if
|
232
|
-
|
233
|
-
|
234
|
-
|
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("In #{WAREHOUSE}")
|
272
|
-
puts
|
389
|
+
puts blue("ghcurl: #{WAREHOUSE}")
|
273
390
|
Dir.children(WAREHOUSE).each_with_index do |dict,i|
|
274
|
-
puts "
|
391
|
+
puts "#{blue(i+1)}. #{bold(green(dict))}"
|
275
392
|
end
|
276
|
-
puts
|
277
393
|
end
|
278
394
|
|
279
395
|
|
396
|
+
#
|
397
|
+
# For -d option
|
398
|
+
#
|
399
|
+
def delete_wares(name)
|
400
|
+
begin
|
401
|
+
|
402
|
+
if name.nil?
|
403
|
+
re = HL.ask "Do you want to delete all downloaded files?"
|
404
|
+
case re.downcase
|
405
|
+
when '','y','ye','yes','true'
|
406
|
+
FileUtils.rm_rf WAREHOUSE
|
407
|
+
log "Delete all done"
|
408
|
+
end
|
409
|
+
else
|
410
|
+
FileUtils.rm WAREHOUSE + '/' + name
|
411
|
+
log "Delete #{name} done"
|
412
|
+
end
|
413
|
+
|
414
|
+
rescue Exception => e
|
415
|
+
puts bold(red("ghcurl: #{e}"))
|
416
|
+
list_wares
|
417
|
+
end
|
418
|
+
|
419
|
+
end # end def delete_wares
|
420
|
+
|
421
|
+
|
280
422
|
def help
|
281
423
|
puts <<~EOC
|
282
424
|
ghcurl (v#{VERSION}): Download files and install from Github releases
|
@@ -284,18 +426,21 @@ module Ghcurl
|
|
284
426
|
Default install to env 'GHCURL_BIN_PATH' or /usr/local/bin
|
285
427
|
|
286
428
|
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 -
|
429
|
+
ghcurl [user]/repo [regexp] => Search latest version with regexp to download
|
430
|
+
ghcurl repo [re] -v tag => Download a specific tag version
|
431
|
+
ghcurl repo [re] -o [path] => Download into path or rename
|
432
|
+
ghcurl repo [re] -i [path] => Download and install to path
|
433
|
+
ghcurl repo [re] -o [path] -i => Download into path and install
|
434
|
+
ghcurl repo [re] -i -r name => Download and install as 'name'
|
435
|
+
ghcurl -l => List downloaded files
|
436
|
+
ghcurl -d [name] => Delete a downloaded file or all
|
437
|
+
ghcurl -h => Print this help
|
294
438
|
|
295
439
|
example:
|
296
440
|
ghcurl bat => Search sharkdp/bat the latest
|
297
441
|
ghcurl cli deb -i => Search cli/cli /deb/
|
298
442
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
443
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
299
444
|
|
300
445
|
EOC
|
301
446
|
end
|
@@ -309,30 +454,30 @@ end
|
|
309
454
|
####################
|
310
455
|
extend Ghcurl
|
311
456
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
457
|
+
class Ghcurl::CLI < CliSwitch
|
458
|
+
option name: 'install', short: '-i', arg_required: 'optional'
|
459
|
+
option name: 'output', short: '-o', long: '--output', arg_required: 'required'
|
460
|
+
option name: 'rename', short: '-r', arg_required: 'required'
|
461
|
+
option name: 'version', short: '-v', arg_required: 'required'
|
462
|
+
option name: 'help', short: '-h', long: '--help', arg_required: 'noarg'
|
463
|
+
option name: 'list', short: '-l', arg_required: 'noarg'
|
464
|
+
option name: 'delete', short: '-d', arg_required: 'optional'
|
465
|
+
end
|
317
466
|
|
318
|
-
|
319
|
-
args, opts = cli.parse(ARGV)
|
467
|
+
args, opts = Ghcurl::CLI.new.parse(ARGV)
|
320
468
|
|
321
469
|
if args.empty? and opts.empty?
|
322
470
|
help
|
323
471
|
exit
|
324
472
|
end
|
325
473
|
|
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
474
|
|
475
|
+
repo_or_name, regexp = args[0], args[1]
|
333
476
|
version = nil
|
334
477
|
need_install = false
|
478
|
+
download_to = nil
|
335
479
|
install_to = nil
|
480
|
+
rename_as = nil
|
336
481
|
|
337
482
|
opts.each do
|
338
483
|
case _1.name
|
@@ -342,11 +487,18 @@ opts.each do
|
|
342
487
|
when 'list'
|
343
488
|
list_wares
|
344
489
|
exit
|
490
|
+
when 'delete'
|
491
|
+
delete_wares(_1.next_arg)
|
492
|
+
exit
|
345
493
|
when 'version'
|
346
494
|
version = _1.next_arg
|
495
|
+
when 'output'
|
496
|
+
download_to = _1.next_arg
|
347
497
|
when 'install'
|
348
498
|
need_install = true
|
349
499
|
install_to = _1.next_arg
|
500
|
+
when 'rename'
|
501
|
+
rename_as = _1.next_arg
|
350
502
|
end
|
351
503
|
end
|
352
504
|
|
@@ -354,16 +506,14 @@ end
|
|
354
506
|
# p repo_or_name
|
355
507
|
# p regexp
|
356
508
|
# p need_install
|
509
|
+
# p download_to
|
357
510
|
# p install_to
|
511
|
+
# p rename_as
|
358
512
|
|
359
513
|
begin
|
360
|
-
download(repo_or_name, regexp, version: version)
|
514
|
+
ware = download(repo_or_name, regexp, version: version, download_to: download_to)
|
361
515
|
if need_install
|
362
|
-
|
363
|
-
install(repo_or_name, place: install_to)
|
364
|
-
else
|
365
|
-
install(repo_or_name)
|
366
|
-
end
|
516
|
+
install(ware, rename_as: rename_as, install_to: install_to)
|
367
517
|
end
|
368
518
|
rescue Interrupt
|
369
519
|
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.0"
|
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.0
|
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
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.3.0
|
55
55
|
description: Download files (and install) from Github releases.
|
56
56
|
email:
|
57
57
|
- ccmywish@qq.com
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.3.
|
91
|
+
rubygems_version: 3.3.11
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Download files (and install) from Github releases
|