3
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
|
# File 'lib/dvdvrconv/options.rb', line 3
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("--config=FILE", String, "Use YAML format FILE.") do |file|
options[:config_file] = file
end
end
begin
remained = parser.parse!(argv)
rescue OptionParser::InvalidArgument => e
abort e.message
rescue OptionParser::MissingArgument => e
case e.args
when ["--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
end
{ opt: options }
end
|