182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/climate/parser.rb', line 182
def parse(arguments, command=self)
parser = self.trollop_parser
begin
options = parser.parse(arguments)
rescue Trollop::CommandlineError => e
if (m = /unknown argument '(.+)'/.match(e.message))
raise UnexpectedArgumentError.new(m[1], command)
elsif (m = /option (.+) must be specified/.match(e.message))
raise MissingArgumentError.new(m[1], command)
elsif /.+ conflicts with .+/.match(e.message)
raise ConflictingOptionError.new(e.message, command)
elsif /.+ requires .+/.match(e.message)
raise MissingArgumentError.new(e.message, command)
else
raise CommandError.new(e.message, command)
end
end
arguments, leftovers =
if @stop_on
[{}, parser.leftovers]
else
[self.parse_arguments(parser.leftovers), []]
end
[arguments, options, leftovers]
end
|