ghcurl 0.4.0 → 0.6.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 +22 -21
- data/bin/ghcurl +346 -96
- data/lib/ghcurl.rb +66 -0
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0069ec92dd2a2638c346d29aec05b591f52556ccee9906c28a3382506d5d5bd6'
|
4
|
+
data.tar.gz: db516685965cfeadfb7e7db426ee8b328e5f6267af1158bbdc21c23e2aeddce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a3fd97dc832a34b358f87a1be6b925e07647e83506545d13384229a42a24f34a6ab4c6c362a3b482b914e5bbff620fa8a0f3aa545dc771db371ad7eb366c7a
|
7
|
+
data.tar.gz: 3b407e1b7b4ebf046621567d9a1aba7d60cbd55754de54b4e85b7c9af583a57054cd7b50868761249ae385f9aded3eae9d5ca0cc8913245e03b14eaa50bc2f09
|
data/README.md
CHANGED
@@ -10,12 +10,31 @@ gem install ghcurl
|
|
10
10
|
|
11
11
|
<br>
|
12
12
|
|
13
|
-
Download files
|
13
|
+
Download files and install from Github releases.
|
14
|
+
|
15
|
+
It's quite easy to use `ghcurl`, because it can recognize your OS and arch, always give you the best option to download by default. What's more, 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`. The best of it is to automatically extract a tar/zip file to make the installation process smooth in a terminal.
|
16
|
+
|
17
|
+
It may be difficult to use it on Windows, welcome contributions!
|
14
18
|
|
15
19
|
</div>
|
16
20
|
|
17
21
|
## Usage
|
18
22
|
|
23
|
+
Things can be easier. We consider these as popular binaries: https://github.com/ibraheemdev/modern-unix
|
24
|
+
|
25
|
+
Notice: `-i` means to install.
|
26
|
+
|
27
|
+
```bash
|
28
|
+
# It knows that's sharkdp/fd
|
29
|
+
ghcurl fd -i
|
30
|
+
|
31
|
+
# Much easier to install rbspy!
|
32
|
+
ghcurl rbspy -i
|
33
|
+
|
34
|
+
# On Linux, it's very handy
|
35
|
+
ghcurl cli -i
|
36
|
+
```
|
37
|
+
|
19
38
|
Download latest deb/rpm package and install, notice the argument `deb` / `rpm` are just regular expressions.
|
20
39
|
```bash
|
21
40
|
ghcurl cli/cli deb -i
|
@@ -25,7 +44,7 @@ ghcurl cli/cli rpm -i
|
|
25
44
|
Normal download
|
26
45
|
```bash
|
27
46
|
# Download latest rbspy-x86_64-unknown-linux-gnu.tar.gz to ~/.cache/ghcurl
|
28
|
-
ghcurl rbspy/rbspy x86_64.*linux
|
47
|
+
ghcurl rbspy/rbspy 'x86_64.*linux'
|
29
48
|
|
30
49
|
# Download rbspy version 0.11.1
|
31
50
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
@@ -40,28 +59,10 @@ ghcurl BetaPictoris/timeleft timeleft -i
|
|
40
59
|
ghcurl BetaPictoris/timeleft timeleft -i ~/tmp/bin
|
41
60
|
|
42
61
|
# Install and rename it to, here, 'gd' in /usr/local/bin
|
43
|
-
ghcurl dlvhdr/gh-dash linux-amd64 -i gd
|
62
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
44
63
|
|
45
64
|
# or, like this
|
46
65
|
ghcurl dlvhdr/gh-dash linux-amd64 -i ~/tmp/bin/gd
|
47
66
|
```
|
48
67
|
|
49
68
|
<br>
|
50
|
-
|
51
|
-
## How does it works?
|
52
|
-
|
53
|
-
For future contributers and myself, I'll tell you how to maintain this.
|
54
|
-
|
55
|
-
In `ghcurl` previous to `0.3.1`, I write this code piece:
|
56
|
-
```ruby
|
57
|
-
unless version
|
58
|
-
# Notice: releases/tag/vx.x.x/download not works!!!
|
59
|
-
# This is a link relocation
|
60
|
-
url = "https://github.com/#{repo}/releases/latest/download/#{ware}"
|
61
|
-
else
|
62
|
-
# The real download link
|
63
|
-
url = "https://github.com/#{repo}/releases/download/v#{version}/#{ware}"
|
64
|
-
end
|
65
|
-
```
|
66
|
-
|
67
|
-
As you can see, it considers the Github router when you try to install a **latest** one, which are very unreliable, and you should specify a precise name for the thing you want to download. So from `0.4.0` I changed this via a slow but useful method: check the HTML file in the release page, and search the string user request which is not necessarily accurate, to find the download link directly.
|
data/bin/ghcurl
CHANGED
@@ -3,23 +3,27 @@
|
|
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-15>
|
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
|
+
require 'ghcurl'
|
14
15
|
require 'nokogiri'
|
15
16
|
require 'open-uri'
|
17
|
+
require 'highline'
|
18
|
+
require 'cliswitch'
|
19
|
+
require 'fileutils'
|
16
20
|
|
17
21
|
module Ghcurl
|
18
22
|
|
19
|
-
VERSION = "0.4.0"
|
20
23
|
WAREHOUSE = File.expand_path("~/.cache/ghcurl")
|
21
|
-
BIN_PATH = "/usr/local/bin"
|
22
|
-
|
24
|
+
BIN_PATH = ENV['GHCURL_BIN_PATH'].chomp('/') || "/usr/local/bin"
|
25
|
+
HL = HighLine.new
|
26
|
+
|
23
27
|
class Error < StandardError; end
|
24
28
|
|
25
29
|
|
@@ -34,23 +38,97 @@ module Ghcurl
|
|
34
38
|
|
35
39
|
|
36
40
|
def curl(url, name)
|
37
|
-
#if !test('d', WAREHOUSE)
|
38
|
-
# require 'fileutils'
|
39
|
-
# FileUtils.mkdir_p(WAREHOUSE)
|
40
|
-
#end
|
41
41
|
cmd = "curl -L #{url} --create-dirs -o #{WAREHOUSE}/#{name}"
|
42
42
|
system cmd
|
43
43
|
log "Downloaded to #{WAREHOUSE}/#{name}"
|
44
44
|
end
|
45
45
|
|
46
46
|
|
47
|
-
def
|
47
|
+
def get_filters
|
48
|
+
|
49
|
+
arches = [
|
50
|
+
['amd64', 'x86_64', 'x64'],
|
51
|
+
['386', 'i686'],
|
52
|
+
['arm64', 'aarch64'],
|
53
|
+
['armv6', 'arm'],
|
54
|
+
]
|
55
|
+
|
56
|
+
oses = [
|
57
|
+
['linux'],
|
58
|
+
['freebsd'],
|
59
|
+
['mac', 'apple', 'darwin'],
|
60
|
+
['windows']
|
61
|
+
]
|
62
|
+
|
63
|
+
fs = RUBY_PLATFORM.split('-')
|
64
|
+
os = ""
|
65
|
+
arch = ""
|
66
|
+
fs.each do |f|
|
67
|
+
case f
|
68
|
+
when 'linux' then os = 'linux'
|
69
|
+
when 'mac','macOS' then os = 'mac'
|
70
|
+
when 'ucrt', 'mingw', 'windows' then os = 'windows'
|
71
|
+
when 'x86_64' then arch = 'x86_64'
|
72
|
+
when 'x86' then arch = 'x86'
|
73
|
+
when 'amd64' then arch = 'amd64'
|
74
|
+
when 'arm64' then arch = 'arm64'
|
75
|
+
when 'armv6' then arch = 'armv6'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
approval, refuse = [], []
|
80
|
+
# [os, arch].each { approval << _1 unless _1.nil? }
|
81
|
+
|
82
|
+
if os
|
83
|
+
i = oses.each_with_index do |type, index|
|
84
|
+
break index if type.include? os
|
85
|
+
end
|
86
|
+
if !i.nil?
|
87
|
+
tmp = oses.dup
|
88
|
+
tmp.delete_at(i)
|
89
|
+
refuse.concat tmp.flatten
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
if arch
|
95
|
+
i = arches.each_with_index do |type, index|
|
96
|
+
break index if type.include? arch
|
97
|
+
end
|
98
|
+
if !i.nil?
|
99
|
+
tmp = arches.dup
|
100
|
+
tmp.delete_at(i)
|
101
|
+
refuse.concat tmp.flatten
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Debug
|
106
|
+
# puts "=> Approval and refuse"
|
107
|
+
# p [os, arch]
|
108
|
+
# p refuse
|
109
|
+
|
110
|
+
# Now we only refuse others
|
111
|
+
return refuse
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def download(repo, regexp, version: nil)
|
48
117
|
|
49
118
|
if repo =~ /^https:\/\/github.com/
|
50
119
|
require 'uri'
|
51
120
|
uri = URI(repo)
|
52
121
|
# index 1, take 2
|
53
122
|
repo = uri.path.split('/')[1,2].join('/')
|
123
|
+
elsif !repo.include?('/')
|
124
|
+
got_repo = DEFAULT_WARES[repo.to_sym]
|
125
|
+
if not got_repo
|
126
|
+
user = HL.ask "Who developed the awesome '#{repo}' ? "
|
127
|
+
repo = user + '/' + repo
|
128
|
+
else
|
129
|
+
repo = got_repo
|
130
|
+
log "Use the popular repo #{repo}"
|
131
|
+
end
|
54
132
|
end
|
55
133
|
|
56
134
|
log "checking..."
|
@@ -68,39 +146,63 @@ module Ghcurl
|
|
68
146
|
The search result is empty, check the args:
|
69
147
|
repo: #{repo}
|
70
148
|
version: #{version ? version:'nil'}
|
71
|
-
|
149
|
+
|
72
150
|
EOE
|
73
151
|
puts
|
74
152
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
153
|
+
|
154
|
+
|
155
|
+
links = links.map { _1['href'] }
|
156
|
+
|
157
|
+
|
158
|
+
if regexp
|
159
|
+
filtered = links.select do
|
160
|
+
_1 =~ /#{regexp}/
|
161
|
+
end
|
162
|
+
else
|
163
|
+
refuse = get_filters()
|
164
|
+
filtered = links.select do |l|
|
165
|
+
refuse.all? do |f|
|
166
|
+
l !~ /#{f}/
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
if filtered.size == 1
|
173
|
+
link = filtered[0].split('/').last
|
174
|
+
else
|
175
|
+
if filtered.size == 0
|
176
|
+
links_for_user = links.map { _1.split('/').last }
|
177
|
+
else
|
178
|
+
links_for_user = filtered.map { _1.split('/').last }
|
179
|
+
end
|
180
|
+
link = HL.choose do |menu|
|
181
|
+
menu.index_color = :rgb_77bbff
|
182
|
+
menu.prompt = "Which one do you want to download? "
|
183
|
+
menu.choices( *links_for_user )
|
184
|
+
end
|
78
185
|
end
|
79
186
|
|
80
|
-
url = "https://github.com" + link
|
187
|
+
url = "https://github.com" + links[0].split('/')[0..-2].join('/') + '/' + link
|
81
188
|
|
82
189
|
log "Downloading #{url}"
|
83
190
|
|
84
|
-
|
85
|
-
|
86
|
-
curl(url, $downloaded)
|
191
|
+
download_name = link.split('/').last
|
87
192
|
|
193
|
+
curl(url, download_name)
|
194
|
+
return download_name
|
88
195
|
end
|
89
196
|
|
90
|
-
def install(ware, place: BIN_PATH)
|
91
|
-
case RUBY_PLATFORM
|
92
|
-
when /ucrt/i, /mingw/i
|
93
|
-
install_on_windows(ware, place)
|
94
|
-
else
|
95
|
-
install_on_nix(ware, place)
|
96
|
-
end
|
97
|
-
log "Install finish!"
|
98
|
-
end
|
99
197
|
|
100
198
|
|
101
|
-
def
|
199
|
+
def install(dl_name, rename_as: nil, install_to: nil)
|
102
200
|
|
103
|
-
|
201
|
+
if install_to.nil?
|
202
|
+
install_to = BIN_PATH
|
203
|
+
end
|
204
|
+
|
205
|
+
target = "#{WAREHOUSE}/#{dl_name}"
|
104
206
|
|
105
207
|
if target.end_with?('.deb')
|
106
208
|
log "Install deb package for you"
|
@@ -115,58 +217,198 @@ module Ghcurl
|
|
115
217
|
end
|
116
218
|
|
117
219
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
220
|
+
#
|
221
|
+
# The zipped file
|
222
|
+
#
|
223
|
+
|
224
|
+
zip_flag = false
|
225
|
+
# unzipped to dir
|
226
|
+
unzip_dir = ""
|
227
|
+
# unzipped files
|
228
|
+
files = ""
|
229
|
+
# our desired software name
|
230
|
+
name = ""
|
231
|
+
|
232
|
+
if target.match?(/\.zip$/) or target.match?(/\.tar\.(\w){1,3}/)
|
233
|
+
|
234
|
+
zip_flag = true
|
235
|
+
|
236
|
+
# unzip
|
237
|
+
if target.match? /\.zip$/
|
238
|
+
log "Unzip zip file"
|
239
|
+
unzip_dir = target.chomp('.zip')
|
240
|
+
system "unzip -q #{target} -d #{unzip_dir}"
|
241
|
+
end
|
242
|
+
|
243
|
+
# .gz, .bz2, .xz
|
244
|
+
if target.match? /\.tar\.(\w){1,3}/
|
245
|
+
log "Unzip tar file"
|
246
|
+
unzip_dir = target.split('.')[0..-3].join('.')
|
247
|
+
FileUtils.mkdir_p(unzip_dir)
|
248
|
+
system "tar xf #{target} --directory=#{unzip_dir}"
|
249
|
+
end
|
250
|
+
|
122
251
|
|
252
|
+
|
253
|
+
def _iterate_dir(dir)
|
254
|
+
result = []
|
255
|
+
chd = Dir.children(dir)
|
256
|
+
chd_files = chd.select{|f| File.file? "#{dir}/#{f}"}
|
257
|
+
|
258
|
+
chd_files.each { result << "#{dir}/#{_1}"[2..] }
|
259
|
+
|
260
|
+
chd_dirs = chd.select{|d| File.directory?("#{dir}/#{d}") && ( d != '.git')}
|
261
|
+
chd_dirs.each do |d|
|
262
|
+
sub_dir = "#{dir}/#{d}"
|
263
|
+
result.concat _iterate_dir(sub_dir)
|
264
|
+
end
|
265
|
+
result
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
Dir.chdir unzip_dir do
|
271
|
+
files = _iterate_dir('.')
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
if files.size > 1
|
276
|
+
name = HL.choose do |menu|
|
277
|
+
menu.index_color = :rgb_77bbff
|
278
|
+
menu.prompt = "Which one do you want to install? "
|
279
|
+
menu.choices( *files )
|
280
|
+
end
|
281
|
+
else
|
282
|
+
name = files[0]
|
283
|
+
end
|
284
|
+
|
285
|
+
end # end of zipped file handle
|
286
|
+
|
287
|
+
|
288
|
+
if !zip_flag
|
289
|
+
# downloaded name in WAREHOUSE
|
290
|
+
name = dl_name
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
if (name.size > 10 ||
|
295
|
+
name.include?('.') ||
|
296
|
+
name.include?('-') ||
|
297
|
+
name.include?('_')) && (not rename_as)
|
298
|
+
log "Do you want to rename the '#{name}'?"
|
299
|
+
re = HL.ask "Input name, or just leave it blank to say no."
|
300
|
+
if !re.empty?
|
301
|
+
rename_as = re
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
if zip_flag
|
307
|
+
# add unzip_dir prefix
|
308
|
+
name = unzip_dir.delete_prefix(WAREHOUSE + '/') + '/' + name
|
309
|
+
end
|
310
|
+
|
311
|
+
if rename_as
|
312
|
+
log "Renamed as '#{rename_as}'"
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
case RUBY_PLATFORM
|
317
|
+
when /ucrt/i, /mingw/i
|
318
|
+
install_on_windows(name, install_to, rename_as)
|
123
319
|
else
|
124
|
-
|
125
|
-
|
126
|
-
|
320
|
+
install_on_nix(name, install_to, rename_as)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
def install_on_nix(name, install_to, rename_as)
|
326
|
+
install_to = install_to.chomp('/')
|
327
|
+
target = WAREHOUSE + '/' + name
|
328
|
+
|
329
|
+
if test 'd', install_to
|
330
|
+
log "Ready to install #{name}"
|
331
|
+
if rename_as
|
332
|
+
dest = "#{install_to}/#{rename_as}"
|
333
|
+
system "sudo cp #{target} " + dest
|
334
|
+
system "sudo chmod +x " + dest
|
335
|
+
log "Installed as " + dest
|
127
336
|
else
|
128
|
-
|
337
|
+
cmd = "sudo install -Dt #{install_to} -m 755 #{target} "
|
338
|
+
system cmd
|
339
|
+
log "Install #{name} to " + install_to
|
129
340
|
end
|
130
|
-
log "
|
131
|
-
|
132
|
-
|
341
|
+
log "Install finish!"
|
342
|
+
else
|
343
|
+
log "#{install_to} is not a directory!"
|
133
344
|
end
|
134
345
|
|
135
346
|
end
|
136
347
|
|
137
348
|
|
138
349
|
def install_on_windows
|
350
|
+
log "Sorry, not implemented yet on Windows! Can you help?"
|
139
351
|
end
|
140
352
|
|
141
353
|
|
354
|
+
#
|
355
|
+
# For -l option
|
356
|
+
#
|
142
357
|
def list_wares
|
143
|
-
|
144
|
-
puts blue("In #{WAREHOUSE}")
|
145
|
-
puts
|
358
|
+
puts blue("ghcurl: #{WAREHOUSE}")
|
146
359
|
Dir.children(WAREHOUSE).each_with_index do |dict,i|
|
147
|
-
puts "
|
360
|
+
puts "#{blue(i+1)}. #{bold(green(dict))}"
|
148
361
|
end
|
149
|
-
puts
|
150
362
|
end
|
151
363
|
|
152
364
|
|
365
|
+
#
|
366
|
+
# For -d option
|
367
|
+
#
|
368
|
+
def delete_wares(name)
|
369
|
+
begin
|
370
|
+
|
371
|
+
if name.nil?
|
372
|
+
re = HL.ask "Do you want to delete all downloaded files?"
|
373
|
+
case re.downcase
|
374
|
+
when '','y','ye','yes','true'
|
375
|
+
FileUtils.rm_rf WAREHOUSE
|
376
|
+
log "Delete all done"
|
377
|
+
end
|
378
|
+
else
|
379
|
+
FileUtils.rm WAREHOUSE + '/' + name
|
380
|
+
log "Delete #{name} done"
|
381
|
+
end
|
382
|
+
|
383
|
+
rescue Exception => e
|
384
|
+
puts bold(red("ghcurl: #{e}"))
|
385
|
+
list_wares
|
386
|
+
end
|
387
|
+
|
388
|
+
end # end def delete_wares
|
389
|
+
|
390
|
+
|
153
391
|
def help
|
154
392
|
puts <<~EOC
|
155
|
-
ghcurl (v#{VERSION}): Download files
|
393
|
+
ghcurl (v#{VERSION}): Download files and install from Github releases
|
394
|
+
|
395
|
+
Default install to env 'GHCURL_BIN_PATH' or /usr/local/bin
|
156
396
|
|
157
397
|
usage:
|
158
|
-
ghcurl
|
159
|
-
ghcurl
|
160
|
-
ghcurl
|
161
|
-
ghcurl
|
162
|
-
ghcurl
|
163
|
-
ghcurl
|
164
|
-
ghcurl -
|
165
|
-
ghcurl -h
|
398
|
+
ghcurl [user]/repo [regexp] => Search latest version with regexp to download
|
399
|
+
ghcurl repo [re] -v tag => Download a specific tag version
|
400
|
+
ghcurl repo [deb/rpm] => Download and install deb/rpm package
|
401
|
+
ghcurl repo [re] -i [path] => Download and install to path
|
402
|
+
ghcurl repo [re] -i -r name => Download and install as 'name'
|
403
|
+
ghcurl -l => List downloaded files
|
404
|
+
ghcurl -d [name] => Delete a downloaded file or all
|
405
|
+
ghcurl -h => Print this help
|
166
406
|
|
167
407
|
example:
|
408
|
+
ghcurl bat => Search sharkdp/bat the latest
|
409
|
+
ghcurl cli deb -i => Search cli/cli /deb/
|
168
410
|
ghcurl rbspy/rbspy 'x86_64.*linux' -v0.11.1
|
169
|
-
ghcurl
|
411
|
+
ghcurl dlvhdr/gh-dash linux-amd64 -i -r 'gd'
|
170
412
|
|
171
413
|
EOC
|
172
414
|
end
|
@@ -180,53 +422,61 @@ end
|
|
180
422
|
####################
|
181
423
|
extend Ghcurl
|
182
424
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
if ware.nil?
|
192
|
-
log "ghcurl: Download what?"
|
193
|
-
log " use: ghcurl repo file"
|
194
|
-
exit
|
425
|
+
class Ghcurl::CLI < CliSwitch
|
426
|
+
option name: 'install', short: '-i', arg_required: 'optional'
|
427
|
+
option name: 'rename', short: '-r', arg_required: 'required'
|
428
|
+
option name: 'version', short: '-v', arg_required: 'required'
|
429
|
+
option name: 'help', short: '-h', long: '--help', arg_required: 'noarg'
|
430
|
+
option name: 'list', short: '-l', arg_required: 'noarg'
|
431
|
+
option name: 'delete', short: '-d', arg_required: 'optional'
|
195
432
|
end
|
196
433
|
|
434
|
+
args, opts = Ghcurl::CLI.new.parse(ARGV)
|
197
435
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
case arg
|
203
|
-
when '-v'
|
204
|
-
download gh_repo, ware, version: ARGV.shift
|
205
|
-
when /-v\d.*/
|
206
|
-
v = arg.split('-v')[1]
|
207
|
-
download gh_repo, ware, version: v
|
208
|
-
else
|
209
|
-
download gh_repo, ware
|
210
|
-
next_op = false
|
436
|
+
if args.empty? and opts.empty?
|
437
|
+
help
|
438
|
+
exit
|
211
439
|
end
|
212
440
|
|
213
441
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
442
|
+
repo_or_name, regexp = args[0], args[1]
|
443
|
+
version = nil
|
444
|
+
need_install = false
|
445
|
+
install_to = nil
|
446
|
+
rename_as = nil
|
447
|
+
|
448
|
+
opts.each do
|
449
|
+
case _1.name
|
450
|
+
when 'help'
|
451
|
+
help
|
452
|
+
exit
|
453
|
+
when 'list'
|
454
|
+
list_wares
|
455
|
+
exit
|
456
|
+
when 'delete'
|
457
|
+
delete_wares(_1.next_arg)
|
458
|
+
exit
|
459
|
+
when 'version'
|
460
|
+
version = _1.next_arg
|
461
|
+
when 'install'
|
462
|
+
need_install = true
|
463
|
+
install_to = _1.next_arg
|
464
|
+
when 'rename'
|
465
|
+
rename_as = _1.next_arg
|
466
|
+
end
|
218
467
|
end
|
219
468
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
469
|
+
# Debug
|
470
|
+
# p repo_or_name
|
471
|
+
# p regexp
|
472
|
+
# p need_install
|
473
|
+
# p install_to
|
474
|
+
# p rename_as
|
475
|
+
|
476
|
+
begin
|
477
|
+
dl_name = download(repo_or_name, regexp, version: version)
|
478
|
+
if need_install
|
479
|
+
install(dl_name, rename_as: rename_as, install_to: install_to)
|
480
|
+
end
|
481
|
+
rescue Interrupt
|
232
482
|
end
|
data/lib/ghcurl.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# ------------------------------------------------------
|
2
|
+
# File : ghcurl.rb
|
3
|
+
# Authors : ccmywish <ccmywish@qq.com>
|
4
|
+
# Created on : <2022-04-12>
|
5
|
+
# Last modified : <2022-04-15>
|
6
|
+
#
|
7
|
+
# ghcurl:
|
8
|
+
#
|
9
|
+
# This is the lib file.
|
10
|
+
#
|
11
|
+
# ------------------------------------------------------
|
12
|
+
|
13
|
+
module Ghcurl
|
14
|
+
|
15
|
+
VERSION = "0.6.0"
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# We consider from this:
|
21
|
+
#
|
22
|
+
# https://github.com/ibraheemdev/modern-unix
|
23
|
+
#
|
24
|
+
Ghcurl::DEFAULT_WARES = {
|
25
|
+
|
26
|
+
cli: 'cli/cli',
|
27
|
+
|
28
|
+
fd: 'sharkdp/fd',
|
29
|
+
bat: 'sharkdp/bat',
|
30
|
+
hyperfine: 'sharkdp/hyperfine',
|
31
|
+
hexyl: 'sharkdp/hexyl',
|
32
|
+
|
33
|
+
exa: 'ogham/exa',
|
34
|
+
dog: 'ogham/dog',
|
35
|
+
|
36
|
+
lsd: 'Peltoche/lsd',
|
37
|
+
delta: 'dandavison/delta',
|
38
|
+
dust: 'bootandy/dust',
|
39
|
+
duf: 'muesli/duf',
|
40
|
+
broot: 'Canop/broot',
|
41
|
+
|
42
|
+
ripgrep: 'BurntSushi/ripgrep',
|
43
|
+
rg: 'BurntSushi/ripgrep',
|
44
|
+
ag: 'ggreer/the_silver_searcher',
|
45
|
+
|
46
|
+
fzf: 'junegunn/fzf',
|
47
|
+
fzy: 'jhawthorn/fzy',
|
48
|
+
|
49
|
+
mcfly: 'cantino/mcfly',
|
50
|
+
choose: 'theryangeary/choose',
|
51
|
+
jq: 'stedolan/jq',
|
52
|
+
sd: 'chmln/sd',
|
53
|
+
cheat: 'cheat/cheat',
|
54
|
+
bottom: 'ClementTsang/bottom',
|
55
|
+
glances: 'nicolargo/glances',
|
56
|
+
gtop: 'aksakalli/gtop',
|
57
|
+
gping: 'orf/gping',
|
58
|
+
procs: 'dalance/procs',
|
59
|
+
httpie: 'httpie/httpie',
|
60
|
+
curlie: 'rs/curlie',
|
61
|
+
xh: 'ducaale/xh',
|
62
|
+
zoxide: 'ajeetdsouza/zoxide',
|
63
|
+
|
64
|
+
scc: 'boyter/scc',
|
65
|
+
rbspy: 'rbspy/rbspy'
|
66
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghcurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cliswitch
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.0
|
27
55
|
description: Download files (and install) from Github releases.
|
28
56
|
email:
|
29
57
|
- ccmywish@qq.com
|
@@ -37,6 +65,7 @@ files:
|
|
37
65
|
- README.md
|
38
66
|
- Rakefile
|
39
67
|
- bin/ghcurl
|
68
|
+
- lib/ghcurl.rb
|
40
69
|
homepage: https://github.com/ccmywish/ghcurl
|
41
70
|
licenses:
|
42
71
|
- MIT
|
@@ -59,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
88
|
- !ruby/object:Gem::Version
|
60
89
|
version: '0'
|
61
90
|
requirements: []
|
62
|
-
rubygems_version: 3.3.
|
91
|
+
rubygems_version: 3.3.11
|
63
92
|
signing_key:
|
64
93
|
specification_version: 4
|
65
94
|
summary: Download files (and install) from Github releases
|