# File lib/mixlib/cli.rb, line 120
    def parse_options(argv=ARGV)
      argv = argv.dup
      @opt_parser = OptionParser.new do |opts|  
        # Set the banner
        opts.banner = banner        
        
        # Create new options
        options.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |opt_key, opt_val|          
          opt_args = build_option_arguments(opt_val)
          
          opt_method = case opt_val[:on]
            when :on
              :on
            when :tail
              :on_tail
            when :head
              :on_head
            else
              raise ArgumentError, "You must pass :on, :tail, or :head to :on"
            end
                      
          parse_block = case opt_val[:boolean]
            when true
              Proc.new() do
                config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(true)) || true
                puts opts if opt_val[:show_options]
                exit opt_val[:exit] if opt_val[:exit]
              end
            when false
              Proc.new() do |c|
                config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c
                puts opts if opt_val[:show_options]
                exit opt_val[:exit] if opt_val[:exit]
              end
            end
                    
          full_opt = [ opt_method ]
          opt_args.inject(full_opt) { |memo, arg| memo << arg; memo }
          full_opt << parse_block
          opts.send(*full_opt)
        end
      end
      @opt_parser.parse!(argv)
      
      # Deal with any required values
      options.each do |opt_key, opt_value|
        if opt_value[:required]
          reqarg = opt_value[:short] || opt_value[:long]
          puts "You must supply #{reqarg}!"
          puts @opt_parser
          exit 2
        end
      end
      
      argv
    end