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
|
# File 'lib/dvdvrconv/options.rb', line 5
def self.parse(argv)
options = {}
parser = OptionParser.new do |o|
o.on_head('-v', '--version', 'Show version') do |v|
options[:version] = v
o.version = Dvdvrconv::VERSION
puts o.version
exit
end
o.on('-i', '--info', 'Show file information') do |v|
options[:info] = v
end
o.on('-c', '--config=FILE', String, 'Use YAML format FILE.') do |file|
options[:config_file] = file
end
o.on('-e', '--exec', 'Execute the VRO file to mp4 conversion.') do |v|
options[:exec] = v
end
end
begin
parser.parse!(argv)
rescue OptionParser::InvalidArgument => e
abort e.message
rescue OptionParser::MissingArgument => e
case e.args
when ['-c'], ['--config']
puts "The config file has not been specified.\nUse the default configuration file. (=> #{Dvdvrconv::DEFAULT_CONFIG_FILE})"
options[:config_file] = Dvdvrconv::DEFAULT_CONFIG_FILE
end
rescue OptionParser::ParseError => e
abort e.message
end
{ opt: options }
end
|