Create options hash from command line arguments

 === Return
 options(Hash):: Hash of options as defined by the command line
14571
def parse_args
      options = { :verbose => false }
      options[:agent_name] = ARGV[0] unless ARGV[0] =~ /^-/

      opts = OptionParser.new do |opts|

        opts.on('-l', '--log-level LEVEL') do |l|
          fail("Invalid log level '#{l}'") unless AgentManager::LEVELS.include?(l.downcase.to_sym)
          options[:level] = l.downcase
        end

        opts.on("-c", "--cfg-dir DIR") do |d|
          options[:cfg_dir] = d
        end

        opts.on('-v', '--verbose') do
          options[:verbose] = true
        end

      end

      opts.on_tail('--help') do
         puts Usage.scan(__FILE__)
         exit
      end

      begin
        opts.parse!(ARGV)
      rescue Exception => e
        exit 0 if e.is_a?(SystemExit)
        fail(e.message + "\nUse 'rlog --help' for additional information")
      end
      options
    end
496657
function(arg_hash){

	if( ! arg_hash ){ arg_hash = {}; }
	var out_keys = [];
	for (var out_key in arg_hash) {
	    if (arg_hash.hasOwnProperty(out_key)) {
		out_keys.push(out_key);
	    }
	}
	
	return out_keys;
    }
1323170
def create_from_hash(hash, ezo):
        '''
        
        '''

        cp, err = ezo.db.get("contracts", hash)
        if err:
            return None, err

        # create a new Contract
        c = Contract(cp["name"], ezo)
        c.abi = cp["abi"]
        c.bin = cp["bin"]
        c.hash = cp["hash"]
        c.source = cp["source"]
        c.timestamp = cp["timestamp"]
        c.te_map = cp['te-map']

        return c, None
905245
def build(option_hash)
      opts = option_hash.dup || {}
      @relation = @base.scoped
      opts.stringify_keys!
      opts = collapse_multiparameter_options(opts)
      assign_attributes(opts)
      self
    end
985509
def key_create(options)
      ssh_key = key_generation(options)
      ssh_private_key_file = options[:private_key]
      ssh_public_key_file = "#{ssh_private_key_file}.pub"

      # TODO: - add to .fenton/config file
      File.write(ssh_private_key_file, ssh_key.private_key)
      File.chmod(0o600, ssh_private_key_file)
      File.write(ssh_public_key_file, ssh_key.ssh_public_key)
      File.chmod(0o600, ssh_public_key_file)

      [true, 'Key': ['creation failed']]
    end
381698
def by_hash_ids(*args)
      cmd_options = args.last.kind_of?(Hash) ? args.last : {}
      
      if args.size == 1 && args.first.kind_of?(Array)
        array = args.first
      else
        array = args
      end      
      return [] if array.empty?

      args = array.map{|hash| " -r#{ hash }"}
      hg_to_array ["log#{ args.join('') } --style ?", style], {:separator => changeset_separator}, cmd_options do |line|
        build(line)
      end
    end
318405
def os_option(option, *args)
      options = args.pop if args.last.is_a?(Hash)
      options ||= {}
      args.push options.merge(os_prefix: true)
      option option, *args
    end
911476
def parsed_args(args)
      args.inject({}) do |memo, method|
        memo.merge(method.is_a?(Hash) ? method : { method => nil })
      end
    end
895330
def create_args(line, namespace):
    
    args = []
    # Using shlex.split handles quotes args and escape characters.
    for arg in shlex.split(line):
      if not arg:
         continue
      if arg[0] == '$':
        var_name = arg[1:]
        if var_name in namespace:
          args.append((namespace[var_name]))
        else:
          raise Exception('Undefined variable referenced in command line: %s' % arg)
      else:
        args.append(arg)
    return args
266559
def init_hash(hash)
    if hash[:parser]
      self.parser=hash[:parser]
    elsif hash[:many]
      init_many hash
    elsif hash[:match]
      init hash[:match]
    elsif hash[:any]
      init_any hash[:any]
    else
      raise "extended-options patterns (specified by a hash) must have either :parser=> or a :match=> set"
    end

    self.name = hash[:as] || self.name
    self.optional ||= hash[:optional] || hash[:optionally]
    self.could_match ||= hash[:could]
    self.negative ||= hash[:dont]
  end
1104621
def process_options options
      options = options.clone
      [:left, :right].each do |key|
        if options.key?(key) && !(options[key].nil?)
          options[key] = File.expand_path options[key]
        end
      end
      options
    end
245676
def to_hash
      OPTIONS.inject({}) do |hash, option|
        key = option.first
        hash[key] = self.send(key)
        hash
      end
    end
406998
def argument(value, options = {})
      return unless @shell.applicable?(options)
      value = value.to_s
      if @shell.requires_escaping?(value)
        value = @shell.escape_value(value)
      end
      @command << ' ' << value
      @last_arg = :argument
    end
651515
def parse_options(args) # :nodoc:
      option_parser_class = self.class.const_get("#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser")
      OptionParsingResult.new.tap { |parsing_result|
        parsing_result.arguments = args
        parsing_result = @global_option_parser.parse!(parsing_result)
        option_parser_class.new(@accepts).parse!(parsing_result, options[:argument_handling_strategy])
      }
    end
278336
def to_hash
      OPTIONS.inject({}) do |hash, option|
        hash.merge(option.to_sym => send(option))
      end
    end
681837
def to_hash
      result = {}
      @lines.entries.each do |section|
        result[section.key] ||= {}
        section.entries.each do |option|
          opts = Array(option)
          val = opts.map { |o| o.respond_to?(:value) ? o.value : o }
          val = val.size > 1 ? val : val.first
          result[section.key][opts.first.key] = val
        end
      end
      result
    end
897553
def create_option(flag, argument = nil)
      return '' unless flag
      flag = flag.to_s
      return " #{argument}" if flag == 'extra'
      set_pandoc_ruby_options(flag, argument)
      if !argument.nil?
        "#{format_flag(flag)} #{argument}"
      else
        format_flag(flag)
      end
    end