parse_both_passes

in chefctl/src/chefctl.rb [1142:1169]


  def parse_both_passes(argv = nil)
    first_pass = argv || ARGV
    second_pass = Array.new(first_pass)
    begin
      parse(first_pass)
    rescue OptionParser::InvalidOption => e
      
      
      Chefctl.logger.debug("Got an invalid argument #{e.args} during the " +
                           'first pass. Ignoring.')
      
      
      
      e.args.each do |a|
        if first_pass.include?(a)
          first_pass.delete(a)
        else
          quit "Couldn't parse #{a}."
        end
      end
      retry
    end
    @first_pass = false
    yield
    parse!(second_pass)
    second_pass
  end