5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/simple-templater/argv_parsing.rb', line 5
def parse!
self.inject(Hash.new) do |options, argument|
case argument
when /^--no-([^=]+)$/ options[$1.gsub("-", "_").to_sym] = false
when /^--([^=]+)$/ options[$1.gsub("-", "_").to_sym] = true
when /^--([^=]+)=([^,]+)$/ key, value = $1, $2
options[key.gsub("-", "_").to_sym] = value.dup
when /^--([^=]+)=(.+)$/ key, value = $1, $2
options[key.gsub("-", "_").to_sym] = value.split(",")
else
raise "Parsing failed on: #{argument}"
end
options
end
end
|