Transform Ruby style options into git command line options
   +options+ is a hash of Ruby style options

 Returns String[]
   e.g. ["--max-count=10", "--header"]
353405
def transform_options(options)
      args = []
      options.keys.each do |opt|
        if opt.to_s.size == 1
          if options[opt] == true
            args << "-#{opt}"
          elsif options[opt] == false
            # ignore
          else
            val = options.delete(opt)
            args << "-#{opt.to_s} '#{e(val)}'"
          end
        else
          if options[opt] == true
            args << "--#{opt.to_s.gsub(/_/, '-')}"
          elsif options[opt] == false
            # ignore
          else
            val = options.delete(opt)
            args << "--#{opt.to_s.gsub(/_/, '-')}='#{e(val)}'"
          end
        end
      end
      args
    end
55316
def _extract_options
      environment.to_options.merge(
        config:      rackup,
        Host:        environment.host,
        Port:        environment.port,
        AccessLog:   []
      )
    end
817698
def run
      option_parser @options
      
      # Check on include version request.
      if @options[:version].value then
	puts "#{@name}, version #{@version}"
	exit
      end

      # Check on include help request.
      if ARGV[0] == 'help' or ARGV[0] == '--help' or ARGV[0] == '-h' then
	# Help arguments apsent, well then display information about application.
	if ARGV.size == 1 then
	  puts
	  puts "*** #{@name} ***".center(80)
	  # Display about info.
	  if @about.size > 0 then
	    puts '** ABOUT:'
	    @about.each do |line|
	      puts "  #{line}"
	    end
	  end
	  # Display usage info.
	  if @usage.size > 0 then
	    puts
	    puts '** USAGE:'
	    @usage.each do |line|
	      puts "  #{line}"
	    end
	  end
	  # Display options info.
	  puts
	  puts '** OPTIONS:'
	  display_options @options
	  # Display commands info
	  if @commands.size > 0 then
	    @commands.each do |c| c.init end
	    puts
	    puts '** COMMANDS:'
	    display_commands @commands
	    puts
	    puts "For details, type: help [COMMAND]"
	  end
	  puts
	# Help arguments exist, find command in application command list.
	else
	  ARGV.delete_at( 0 )
	  cmd = command_select
	  if ARGV.size != 0 then
	    puts "fatal error: unknown command '#{ARGV[0]}'"
	    exit
	  end
	  # Display describe information on command.
	  puts
	  puts Cmdlib::Describe.outtitle( cmd.name )
	  puts "  #{cmd.brief}"
	  if cmd.details.size > 0 then
	    puts
	    puts '** DETAILS:'
	    cmd.details.each do |e|
	      puts "  #{e}"
	    end
	  end
	  if cmd.example.size > 0 then
	    puts
	    puts '** EXAMPLE:'
	    cmd.example.each do |e|
	      puts "  #{e}"
	    end
	  end
	  # Display options info.
	  if cmd.options.size > 0 then
	    puts
	    puts '** OPTIONS:'	  
	    display_options cmd.options
	  end
	  # Display commands info.
	  if cmd.subcmd.size > 0 then
	    cmd.subcmd.each do |c| c.init end
	    puts
	    puts '** SUBCOMMANDS:'
	    display_commands cmd.subcmd
	    puts
	    puts "For details, type: help #{cmd.name} [SUBCOMMAND]"
	  end
	  puts
	end
	exit
      end
      
      # Handling default command (if exist her).
      if @default != nil then
	option_excess
	if ARGV.size < @default.argnum then
	  puts "fatal error: to few arguments for programm, use <help>."
	else
	  @default.handler( @options, ARGV )
	end
	exit
      end
      
      # Handling commands.
      cmd = command_select
      if cmd == nil then
	puts "fatal error: unknown command or command miss, use <help>."
	exit
      end
      if ARGV.size < cmd.argnum then
	puts "fatal error: to few arguments for command, use: <help> <command name>."
	exit
      end
      # Scaning options fir this command
      option_parser cmd.options
      option_excess
      #cmd.init
      cmd.handler( @options, ARGV )
      exit
    end
897703
def normalized_author_title_params(options)
      raise ArgumentError.new("Need a Hash argument, got #{options.inspect}") unless options.kind_of?(Hash)

      # Symbolize keys please
      #options = options.inject({}){ |h, (k, v)| hash.merge( (k.respond_to?(:to_sym) ? k.to_sym : k) => v )  }

      title           = options[:title].dup  if options[:title]
      author          = options[:author].dup if options[:author]

      
      title  = normalized_title(title, :max_title_words => options[:max_title_words])
      author = normalized_author(author)

      results = {}
      results[:title] = title if title && ! title.empty?
      results[:author] = author if author && ! author.empty?
      
      return results
    end
868611
def concatenating_merge(options, options2, *args)
      options = call_each_hash_value_with_params(options, *args) || {}
      options2 = call_each_hash_value_with_params(options2, *args) || {}


      options.symbolize_keys.merge(options2.symbolize_keys) do |key, v1, v2|
        if v1.is_a?(String) && v2.is_a?(String)
          "#{v1} #{v2}"
        else
          v2
        end
      end
    end
1308800
def prepare_options(options)
      options = engine.config.to_hash.merge(options)
      options.keys.each { |k| options[k.to_s.gsub(/_([a-z])/) { $1.upcase }.to_sym] = options[k] }
      options.delete_if { |k, v| v.nil? }
    end
1034286
def run(prefix, cmd, postfix, options, args, &block)
      timeout  = options.delete(:timeout) rescue nil
      timeout  = true if timeout.nil?

      base     = options.delete(:base) rescue nil
      base     = true if base.nil?

      if input = options.delete(:input)
        block = lambda { |stdin| stdin.write(input) }
      end

      opt_args = transform_options(options)

      if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/
        ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|' || Grit.no_quote) ? a : "\"#{e(a)}\"" }
        gitdir = base ? "--git-dir=\"#{self.git_dir}\"" : ""
        call = "#{prefix}#{Git.git_binary} #{gitdir} #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
      else
        ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|' || Grit.no_quote) ? a : "'#{e(a)}'" }
        gitdir = base ? "--git-dir='#{self.git_dir}'" : ""
        call = "#{prefix}#{Git.git_binary} #{gitdir} #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
      end

      Grit.log(call) if Grit.debug
      response, err = timeout ? sh(call, &block) : wild_sh(call, &block)
      Grit.log(response) if Grit.debug
      Grit.log(err) if Grit.debug
      response
    end
729836
def basic_options
      Hash[BASIC_OPTION_KEYS.map { |k| [k, send(k)] }].reject {|_,v| v.nil?}
    end
251020
def token_and_options(header)
      token = header.to_s.match(/^Token (.*)/) { |m| m[1] }
      if token
        begin
          values = Hash[token.split(',').map do |value|
            value.strip!                      # remove any spaces between commas and values
            key, value = value.split(/\=\"?/) # split key=value pairs
            value.chomp!('"')                 # chomp trailing " in value
            value.gsub!(/\\\"/, '"')          # unescape remaining quotes
            [key, value]
          end]
          [values.delete("token"), values]
        rescue => error
          raise UnprocessableHeader, error
        end
      else
        [nil,{}]
      end
    end
590181
def extract_options(names)
      options = {}
      options = names.pop if names.last.kind_of? Hash
      options = { :desc => @next_desc, 
                  :long_desc => @next_long_desc,
                  :default_value => @next_default_value,
                  :arg_name => @next_arg_name}.merge(options)
    end
1154219
def options
      map = Config.class_variables.map do |key|
        [key.to_s.tr('@', '').to_sym, class_variable_get(:"#{key}")]
      end
      Hash[map]
    end
1211838
def to_ruby_method!(allow_bangs = true)
      leader, trailer = @wrapped_string.strip.scan(/\A(.+)(.)\z/).flatten
      leader          = leader.to_s
      trailer         = trailer.to_s
      if allow_bangs
        trailer.downcase!
        trailer.gsub!(/[^a-z0-9!=\\?]/, '')
      else
        trailer.downcase!
        trailer.gsub!(/[^a-z0-9]/, '')
      end
      id = leader.to_identifier
      id.transliterate!
      id.to_ascii!
      id.clean!
      id.word_chars!
      id.clean!
      @wrapped_string = id.to_s + trailer
      if @wrapped_string == ""
        raise Error, "Input generates impossible Ruby method name"
      end
      with_separators!("_")
    end
7984
def parse(args)
      args = build_opts(args)

      OptionParser.new do |opts|
        opts.banner = 'Usage: undercover [options]'

        opts.on_tail('-h', '--help', 'Prints this help') do
          puts(opts)
          exit
        end

        opts.on_tail('--version', 'Show version') do
          puts VERSION
          exit
        end

        lcov_path_option(opts)
        project_path_option(opts)
        git_dir_option(opts)
        compare_option(opts)
        ruby_syntax_option(opts)
        # TODO: parse dem other options and assign to self
        # --quiet (skip progress bar)
        # --exit-status (do not print report, just exit)
      end.parse(args)

      guess_lcov_path unless lcov
      self
    end
878617
def html_safe_options(hash)
      hash.inject({}) do |result, (key, value)|
        result[key] = case value
          when String
            ERB::Util.h(value)
          else
            value
          end

        result
      end
    end
1206562
def options_to_argv(options)
      argv = []
      options.each do |key, val|
        if key.to_s.size == 1
          if val == true
            argv << "-#{key}"
          elsif val == false
            # ignore
          else
            argv << "-#{key}"
            argv << val.to_s
          end
        else
          if val == true
            argv << "--#{key.to_s.tr('_', '-')}"
          elsif val == false
            # ignore
          else
            argv << "--#{key.to_s.tr('_', '-')}=#{val}"
          end
        end
      end
      argv
    end
1128537
def parse_options!(args)
			@options = {}
			opts = ::OptionParser.new do |opts|
				opts.banner = "Usage: syswatch [options]\n\n  Options:"

				opts.on("-f", "--foreground", "Do not daemonize, just run in foreground.") do |f|
					@options[:foreground] = f
				end

				opts.on("-v", "--verbose", "Be verbose, print out some messages.") do |v|
					@options[:verbose] = v
				end

				opts.on("-t", "--test", "Test notifications.") do |t|
					@options[:test] = t
				end

				opts.on("-c", "--config [FILE]", "Use a specific config file, instead of `#{SysWatch::DEFAULTS[:config]}`") do |config|
					@options[:config] = config
				end
			end
			opts.parse! args
		end
703311
def parse_args
      parser = Trollop::Parser.new do
        opt :list
        opt :add, "", :type => :string
        opt :remove, "", :type => :string
        opt :query, "", :type => :strings
        opt :verbose
        opt :die, "", :short => "-e"
        opt :format, "", :type => :string, :default => "json"
        opt :timeout, "", :type => :int, :default => TAG_REQUEST_TIMEOUT
        version ""
      end

      parse do
        options = parser.parse
        options[:action] = :get_tags if options.delete(:list)
        if options[:add]
          options[:action] = :add_tag
          options[:tag] = options.delete(:add).strip
          raise ::Trollop::CommandlineError.new("Non-empty value required") if options[:tag].empty?
        end
        if options[:remove]
          options[:action] = :remove_tag
          options[:tag] = options.delete(:remove).strip
          raise ::Trollop::CommandlineError.new("Non-empty value required") if options[:tag].empty?
        end
        if options[:query]
          options[:action] = :query_tags
          options[:tags] = options.delete(:query).map { |tag| tag.strip }
        end
        options[:format] = parse_format(options[:format])
        options
      end
    end