4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/OptsParser.rb', line 4
def get_options!(argv)
options = {}
options[:action] = :perform
options[:quality] = '1080'
options[:output] = ::File.join(".")
options[:no_download] = false
parser = OptionParser.new do |opts|
opts.banner = [
'JVCGet: Get video link for JVC Chronique or download them.',
''
].join("\n")
opts.separator 'Options:'
opts.on('-u', '--url [URL]', "URL of the JVC Chronique.") do |value|
options[:url] = value
end
opts.on('-q', '--quality [1080|720|400|272]', "Video Quality to download. Defaults to #{options[:quality]}.") do |value|
options[:quality] = value
end
opts.on('-o', '--output [/path/to/save/video]', "Path where you want to download the video.") do |value|
options[:output] = value
end
opts.on('-n', '--no_download', "Do not download video just output URL. Defaults to #{options[:no_download]}") do |_value|
options[:no_download] = true
end
opts.on_tail('-d', '--debug', 'Run in debug mode') do |_n|
ENV['DEBUG'] = 'true'
end
opts.on_tail('-h', '--help', 'Display help') do |_n|
options[:action] = :help
end
end
parser.parse!(argv)
if :help == options[:action]
puts parser.to_s
exit
else
unless options[:url]
puts '--url is mandatory.'
puts parser.to_s
abort
end
end
options
end
|