# File lib/puppet/application.rb, line 329
329:   def parse_options
330:     # Create an option parser
331:     option_parser = OptionParser.new(self.class.banner)
332: 
333:     # Add all global options to it.
334:     Puppet.settings.optparse_addargs([]).each do |option|
335:       option_parser.on(*option) do |arg|
336:         handlearg(option[0], arg)
337:       end
338:     end
339: 
340:     # Add options that are local to this application, which were
341:     # created using the "option()" metaprogramming method.  If there
342:     # are any conflicts, this application's options will be favored.
343:     self.class.option_parser_commands.each do |options, fname|
344:       option_parser.on(*options) do |value|
345:         # Call the method that "option()" created.
346:         self.send(fname, value)
347:       end
348:     end
349: 
350:     # scan command line.
351:     begin
352:       option_parser.parse!(self.command_line.args)
353:     rescue OptionParser::ParseError => detail
354:       $stderr.puts detail
355:       $stderr.puts "Try 'puppet #{command_line.subcommand_name} --help'"
356:       exit(1)
357:     end
358:   end