Process options passed either via arglist or via command line args.
509493
def process_options(arglist=None):
    
    global options, args
    usage = "%prog [options] input ..."
    parser = OptionParser(usage)
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help="print status messages, or debug with -vv")
    parser.add_option('-q', '--quiet', default=0, action='count',
                      help="report only file names, or nothing with -qq")
    parser.add_option('--exclude', metavar='patterns', default=default_exclude,
                      help="skip matches (default %s)" % default_exclude)
    parser.add_option('--filename', metavar='patterns',
                      help="only check matching files (e.g. *.py)")
    parser.add_option('--ignore', metavar='errors', default='',
                      help="skip errors and warnings (e.g. E4,W)")
    parser.add_option('--repeat', action='store_true',
                      help="show all occurrences of the same error")
    parser.add_option('--show-source', action='store_true',
                      help="show source code for each error")
    parser.add_option('--show-pep8', action='store_true',
                      help="show text of PEP 8 for each error")
    parser.add_option('--statistics', action='store_true',
                      help="count errors and warnings")
    parser.add_option('--benchmark', action='store_true',
                      help="measure processing speed")
    parser.add_option('--testsuite', metavar='dir',
                      help="run regression tests from dir")
    parser.add_option('--doctest', action='store_true',
                      help="run doctest on myself")
    options, args = parser.parse_args(arglist)
    if options.testsuite:
        args.append(options.testsuite)
    if len(args) == 0:
        parser.error('input not specified')
    options.prog = os.path.basename(sys.argv[0])
    options.exclude = options.exclude.split(',')
    for index in range(len(options.exclude)):
        options.exclude[index] = options.exclude[index].rstrip('/')
    if options.filename:
        options.filename = options.filename.split(',')
    if options.ignore:
        options.ignore = options.ignore.split(',')
    else:
        options.ignore = []
    options.counters = {}
    options.messages = {}

    return options, args
1261735
def parse_args( self, args = None, values = None ):
        '''
        
        '''
        q = multiproc.Queue()
        p = multiproc.Process(target=self._parse_args, args=(q, args, values))
        p.start()
        ret = q.get()
        p.join()
        return ret
1226149
def process_options(opts, config)
      options.each do |option|
        opts.on(*option.for_option_parser) do |x|
          config[map[option]] = x
        end
      end
    end
182194
def parse_args():
  ''' 
  '''
  parser = optparse.OptionParser()

  parser.add_option("-v", "--verbose", action="store_true")

  mode_group = optparse.OptionGroup(parser, "Program Mode")
  mode_group.add_option("-u", "--update-status", action="store_const",
                        dest="mode", const="update_status")
  mode_group.add_option("-g", "--generate-cfg", action="store_const",
                        dest="mode", const="generate_cfg")
  parser.add_option_group(mode_group)
  parser.set_defaults(mode="update_status")

  general_options = optparse.OptionGroup(parser, "CM API Configuration")
  general_options.add_option("-H", "--host", metavar="HOST",
                             help="CM API hostname")
  general_options.add_option("-p", "--port", help="CM API port", default=None)
  general_options.add_option("-P", "--passfile", metavar="FILE",
                             help="File containing CM API username and password, "
                                  "colon-delimited on a single line.  E.g. "
                                  "\"user:pass\"")
  general_options.add_option("--use-tls", action="store_true",
                             help="Use TLS", default=False)
  parser.add_option_group(general_options)

  polling_options = optparse.OptionGroup(parser, "Status Update Options")
  polling_options.add_option("-c", "--cmd-file", metavar="FILE",
                             help="Path to the file that Nagios checks for "
                                  "external command requests.")
  polling_options.add_option("-n", "--use-send-nsca", action="store_true",
                             default=False,
                             help="Use send_nsca to report status via a nsca "
                                  "daemon. When using this option, the "
                                  "send_nsca program must be available and the "
                                  "nsca daemon host and port must be provided."
                                  "Default is false.")
  polling_options.add_option("--send-nsca-path", metavar="PATH",
                             default="/usr/sbin/send_nsca",
                             help="Path to send_nsca, default is "
                                  "/usr/sbin/send_nsca")
  polling_options.add_option("--nsca-host", metavar="HOST",
                             default="localhost",
                             help="When using send_nsca, the hostname of NSCA "
                                  "server, default is localhost.")
  polling_options.add_option("--nsca-port", metavar="PORT", default=None,
                             help="When using send_nsca, the port on which the "
                                  "server is running, default is 5667.")
  polling_options.add_option("--send-nsca-config", metavar="FILE", default=None,
                             help="Config file passed to send_nsca -c. Default"
                                  " is to not specify the config parameter.")
  parser.add_option_group(polling_options)


  generate_options = optparse.OptionGroup(parser, "Generate Config Options")
  generate_options.add_option("--cfg-dir", metavar="DIR", default=getcwd(),
                              help="Directory for generated Nagios cfg files.")
  parser.add_option_group(generate_options)

  (options, args) = parser.parse_args()

  ''' Parse the 'passfile' - it must contain the username and password,
      colon-delimited on a single line. E.g.:
      $ cat ~/protected/cm_pass
      admin:admin
  '''
  required = ["host", "passfile"]

  if options.mode == "update_status":
    if not options.use_send_nsca:
      required.append("cmd_file")

  for required_opt in required:
    if getattr(options, required_opt) is None:
      parser.error("Please specify the required argument: --%s" %
                   (required_opt.replace('_','-'),))

  return (options, args)
685454
def command_with_options(self):
        """"""
        if 'args' in self.config:
            return ' '.join((self.command, self.config['args']))
        return self.command
251319
def parse_options(self, prog_name, arguments):
        """"""
        # Don't want to load configuration to just print the version,
        # so we handle --version manually here.
        if '--version' in arguments:
            self.exit_status(self.version, fh=sys.stdout)
        parser = self.create_parser(prog_name)
        options, args = parser.parse_args(arguments)
        return options, args
580457
def process(self, argument_list):
        
        arg_index = 0
        for a in argument_list:
            opt_and_val = a.split("=", 1)
            opt_name = opt_and_val[0]
            try:
                # option
                argument = self.options[opt_name]
            except KeyError:
                # argument
                try:
                    argument = self.arguments[arg_index]
                except IndexError:
                    logger.error("option/argument %r not specified", a)
                    raise NoSuchOptionOrArgument("No such option or argument: %r" % opt_name)
            logger.info("argument found: %s", argument)

            safe_arg_name = normalize_arg_name(argument.name)  # so we can access names-with-dashes

            logger.info("argument is available under name %r", safe_arg_name)

            if isinstance(argument, Argument):
                arg_index += 1
                value = (a, )
            else:
                try:
                    value = (opt_and_val[1], )
                except IndexError:
                    value = tuple()

            arg_val = argument.action(*value)

            logger.info("argument %r has value %r", safe_arg_name, arg_val)
            self.given_arguments[safe_arg_name] = arg_val
        return self.given_arguments
1307611
function processOptions(opt) {
        keys(opt).forEach(function (key) {
            var value = opt[key];
            if (typeof value === 'string') {
                opt[key] = grunt.template.process(value);
            } else if (Array.isArray(value)) {
                opt[key] = value.slice().map(function (i) {
                    return grunt.template.process(i);
                });
            }
        });
    }
1006140
private function processOptions(RawArgs $args, Command $currentCommand, array $optionsToTest)
    {
        foreach ($optionsToTest as $option) {
            $commands = $currentCommand->getNamedSubCommands();

            if (!$commands->contains($option)) {
                continue;
            }

            $nextCommand = $commands->get($option);

            if (!$nextCommand->getConfig() instanceof OptionCommandConfig) {
                break;
            }

            $currentCommand = $nextCommand;
        }

        return $this->processDefaultSubCommands($args, $currentCommand);
    }
677301
def _options():
    """"""
    opts = sys.argv[1:]
    return [click.Option((v.split('=')[0],)) for v in opts
            if v[0] == '-' and v != '--help']
182522
def handle_command_line_options(args):
    
    for enabled_log in args.enabled_loggers:
        enable_logger(enabled_log)
    for credential_file in args.credential_files:
        settings.load_credentials_from_filepath(credential_file)
    if args.echo:
        from okcupyd import db
        db.echo = True
        db.Session.kw['bind'].echo = True
    return args
928484
def to_args(self):
        
        def has_value(name, value):
            """ Test for non-null option values.
            """
            null_values = ("False", "None", "[]", '""', "''", "0")
            if not value or value in null_values:
                return False
            if name in _arg_defaults:
                if str(value) == str(_arg_defaults[name]):
                    return False
            return True

        def filter_opt(name, value):
            """ Filter out preset and null-valued options.
            """
            if name in ("add_preset", "del_preset", "desc", "note"):
                return False
            return has_value(name, value)

        def argify(name, value):
            """ Convert sos option notation to command line arguments.
            """
            # Handle --verbosity specially
            if name.startswith("verbosity"):
                arg = "-" + int(value) * "v"
                return arg

            name = name.replace("_", "-")

            value = ",".join(value) if _is_seq(value) else value

            if value is not True:
                opt = "%s %s" % (name, value)
            else:
                opt = name

            arg = "--" + opt if len(opt) > 1 else "-" + opt
            return arg

        opt_items = sorted(self.dict().items(), key=lambda x: x[0])
        return [argify(n, v) for (n, v) in opt_items if filter_opt(n, v)]
87228
def add_command_line_options_argparse(cls, argparser):
        """"""
        import argparse

        class SetParameter(argparse.Action):
            """callback object for ArgumentParser"""

            def __call__(self, parser, namespace, value, option_string=None):
                cls.config[option_string] = value
                if option_string == "--stomp-conf":
                    cls.load_configuration_file(value)

        argparser.add_argument(
            "--stomp-host",
            metavar="HOST",
            default=cls.defaults.get("--stomp-host"),
            help="Stomp broker address, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-port",
            metavar="PORT",
            default=cls.defaults.get("--stomp-port"),
            help="Stomp broker port, default '%(default)s'",
            type=int,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-user",
            metavar="USER",
            default=cls.defaults.get("--stomp-user"),
            help="Stomp user, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-pass",
            metavar="PASS",
            default=cls.defaults.get("--stomp-pass"),
            help="Stomp password",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-prfx",
            metavar="PRE",
            default=cls.defaults.get("--stomp-prfx"),
            help="Stomp namespace prefix, default '%(default)s'",
            type=str,
            action=SetParameter,
        )
        argparser.add_argument(
            "--stomp-conf",
            metavar="CNF",
            default=cls.defaults.get("--stomp-conf"),
            help="Stomp configuration file containing connection information, disables default values",
            type=str,
            action=SetParameter,
        )
1185179
def try_process(flag, arg)
      if option = matching_option(flag)
        process(option, arg)
      elsif flag.start_with?("--no-") && option = matching_option(flag.sub("no-", ""))
        process(option, false)
      elsif flag =~ /\A-[^-]{2,}/
        try_process_smashed_arg(flag) || try_process_grouped_flags(flag, arg)
      else
        if flag.start_with?("-") && !suppress_errors?
          raise UnknownOption.new("unknown option `#{flag}'", "#{flag}")
        end
      end
    end
576308
def handle_option(self, opt):
        """"""
        self.options.append(opt)
        log.debug('options: %s', self.options)
1338770
def process_command(cmd, args)
      commands.each do |command, options|
        if (options[:case_sensitive]  && cmd == command) ||
           (!options[:case_sensitive] && cmd.downcase == command.downcase)
          #return options[:block].call(args)
          return instance_exec(args, &options[:block])
        end
      end
      throw :command_not_found
    end
1187805
def _parse_args(self, args=None, values=None):
        """"""
        options, arguments = self._parser.parse_args(args, values)
        return self._fix_set_options(options), arguments