/*
Configure global options for the command line argument parser.
546924
function(parser) {

  // Validate.
  if (!_.isObject(parser)) {
    throw new TypeError('Invalid yargs object: ' + pp(parser));
  }

  // Help option.
  parser.option('h', {
    alias: 'help',
    type: 'boolean',
    describe: 'Display help message.'
  });

  // Verbose option.
  parser.option('v', {
    alias: 'verbose',
    type: 'boolean',
    describe: 'Use verbose output.'
  });

  // Debug option.
  parser.option('d', {
    alias: 'debug',
    type: 'boolean',
    describe: 'Use debug output.'
  });

}
818659
def setOptions(self, glob=False, **kwargs):
        
        if glob:
            self.globalOptions.update(kwargs)
        else:
            self.options.update(kwargs)
734065
def parse_options(metadata):
    """"""
    parser = argparse.ArgumentParser(description='%(prog)s usage:',
                                     prog=__prog__)
    setoption(parser, metadata=metadata)
    return parser
181428
public static RunOptions parseRunCommand(String[] args) throws CliArgsException {
		try {
			DefaultParser parser = new DefaultParser();
			CommandLine line = parser.parse(RUN_OPTIONS, args, true);
			return new RunOptions(line);
		}
		catch (ParseException e) {
			throw new CliArgsException(e.getMessage());
		}
	}
805473
def _parser_options():
    """"""
    import argparse
    parser = argparse.ArgumentParser(description="UNCLE Cron Server")
    parser.add_argument("-examples", action="store_true",
                        help="Display examples of how to use this script.")
    parser.add_argument("-setup", action="store_true",
                        help=("Setup the cron tab and script database for this server so "
                              "that it is ready to have repositories installed."))
    parser.add_argument("-rollback", action="store_true",
                        help=("Remove this script's cron tab and reverse other things done "
                              "by this script. This does not delete this script."))
    parser.add_argument("-enable", action="store_true",
                        help="Re-enable the continuous integration server.")
    parser.add_argument("-disable", action="store_true",
                        help=("Disable the continuous integration server so that it no longer "
                              "monitors the installed repositories."))
    parser.add_argument("-cron", action="store_true",
                        help=("Run the continuous integration routines for all the repos installed "
                              "in this script's database."))
    parser.add_argument("-list", action="store_true",
                        help="List all the repositories in the CI server's database.")
    parser.add_argument("-install", nargs="+",
                        help=("Install the specified XML file(s) as repositories to be monitored "
                              "by the CI server."))
    parser.add_argument("-uninstall", nargs="+",
                        help=("Uninstall the specified XML file(s) as repositories from "
                              "the CI server."))
    parser.add_argument("--verbose", nargs="?", type=int, const=1,
                        help="Runs the CI server in verbose mode.")
    parser.add_argument("-cronfreq", type=int, default=1,
                        help="Specify the frequency at which the cron runs.")
    parser.add_argument("-nolive", action="store_true",
                        help=("For unit testing, when specified no live requests are made to "
                              "servers and all the class actions are performed in test mode. "
                              "This also prevents the cron tab from being installed."))

    global args
    args = vars(parser.parse_known_args()[0])

    if args["examples"]:
        examples()
        exit(0)

    return args
778844
def set_from_args(options)
      assign(options)
    rescue ConfigError => e
      alert_logger.warn format(
        'Failed to configure from arguments: %s',
        e.message
      )
    end
213181
def _apply2parser(arguments, options, parser):
    
    for args, kwargs in options:
        parser.option(*args, **kwargs)
    for args, kwargs in arguments:
        parser.argument(*args, **kwargs)
    return parser
178052
private GlobalOptions createGlobalOptions(CommandLine parsedOpts) {
    String host = parsedOpts.hasOption(HOST_OPT) ?
            parsedOpts.getOptionValue(HOST_OPT) : DEFAULT_REST_SERVER_HOST;
    int port = DEFAULT_REST_SERVER_PORT;
    try {
      if (parsedOpts.hasOption(PORT_OPT)) {
        port = Integer.parseInt(parsedOpts.getOptionValue(PORT_OPT));
      }
    } catch (NumberFormatException e) {
      printHelpAndExit("The port must be a valid integer.");
    }

    return new GlobalOptions(host, port);
  }
53
def add_arguments(self, parser):
        """"""
        parser.add_argument(self._source_param, **self._source_kwargs)
        parser.add_argument('--base', '-b', action='store',
            help=   'Supply the base currency as code or a settings variable name. '
                    'The default is taken from settings CURRENCIES_BASE or SHOP_DEFAULT_CURRENCY, '
                    'or the db, otherwise USD')
57636
public static function configure(){
        $args = func_get_args();
        $numArgs = func_num_args();

        switch ($numArgs) {
            case 1:{
                if (is_array($args[0])){
                    self::configureWithOptions($args[0]);
                } else {
                    self::configureWithDsnAndOptions($args[0]);
                }
                break;
            }
            case 2:{
                if (is_array($args[0])){
                    self::configureWithOptions($args[0], $args[1]);
                } else {
                    self::configureWithDsnAndOptions($args[0], $args[1]);
                }
                break;
            }
            case 3: {
                self::configureWithDsnAndOptions($args[0], $args[1], $args[2]);
                break;
            }
        }
    }
1124967
public function setAdditionalCliParams()
    {
        $reservedParams = explode(',', self::RESERVED_CLI_PARAMS);
        
        $params = [];
        
        $ac = 1;
        while ($ac < (count($_SERVER['argv']))) {
            $paramName = substr($_SERVER['argv'][$ac], 1);
            if (! in_array($paramName, $reservedParams)) {
                $params[$paramName] = $_SERVER['argv'][$ac + 1];
            }
            $ac += 2;
        }
        
        foreach ($params as $param => $value) {
            $this->setParam($param, $value);
        }
    }
206533
protected void configure(String[] args) throws IOException {
    for (String arg : args) {
      if (arg.startsWith("--input=")) {
        FileRef ref = createInput();
        ref.setPath(arg.substring(arg.indexOf('=') + 1));
      } else if (arg.startsWith("--output=")) {
        FileRef ref = createOutput();
        ref.setPath(arg.substring(arg.indexOf('=') + 1));
      } else if (arg.startsWith("--libdefined=")) {
        FunctionNamePredicate libdefined = new FunctionNamePredicate();
        libdefined.setPattern(arg.substring(arg.indexOf('=') + 1));
        addConfiguredLibdefined(libdefined);
      } else {
        throw new IllegalArgumentException(arg);
      }
    }
  }
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
426918
def add_arguments(self, parser):
        '''

        '''
        commands = set(name[3:] for name in dir(self) if name.startswith('do_'))
        parser.add_argument('action', help='action to run', nargs='?',
                            choices=list(commands))
        parser.add_argument('arguments', help='arguments specific to ACTION',
                            nargs=argparse.REMAINDER)
953055
function Argument(handler, options, desc) {
  if (!options.hasOwnProperty('scope')) {
    options.scope = 'global';
  }
  this._parent = null;
  this._name = null;
  this._options = options;
  this._desc = desc;
  this._handler = handler;
  return this;
}
1241392
def init(parser = None):
    

    global p,subparsers
    if parser is None:
        p = argparse.ArgumentParser()
    else:
        p = parser

    arg = p.add_argument

    subparsers = p.add_subparsers()
495417
def _add_arguments(self):
        """"""
        self._parser.add_argument(
            '-v', '--version',
            action='store_true',
            help="show program's version number and exit")
        self._parser.add_argument(
            '-a', '--alias',
            nargs='?',
            const=get_alias(),
            help='[custom-alias-name] prints alias for current shell')
        self._parser.add_argument(
            '-l', '--shell-logger',
            action='store',
            help='log shell output to the file')
        self._parser.add_argument(
            '--enable-experimental-instant-mode',
            action='store_true',
            help='enable experimental instant mode, use on your own risk')
        self._parser.add_argument(
            '-h', '--help',
            action='store_true',
            help='show this help message and exit')
        self._add_conflicting_arguments()
        self._parser.add_argument(
            '-d', '--debug',
            action='store_true',
            help='enable debug output')
        self._parser.add_argument(
            '--force-command',
            action='store',
            help=SUPPRESS)
        self._parser.add_argument(
            'command',
            nargs='*',
            help='command that should be fixed')