manages options when called from command line
4676
def main(args=None):
    
    parser = ArgumentParser(usage=__usage__)
    parser.add_argument("--no-skip-hidden", action="store_false",
                        dest="skip_hidden",
                        help="Do not skip hidden files. "
                        "Use this if you know what you are doing...")
    parser.add_argument("--include", dest="includes", action="append",
                        help="Only replace in files matching theses patterns")
    parser.add_argument("--exclude", dest="excludes", action="append",
                        help="Ignore files matching theses patterns")
    parser.add_argument("--backup",
                        action="store_true", dest="backup",
                        help="Create a backup for each file. "
                             "By default, files are modified in place")
    parser.add_argument("--go",
                        action="store_true", dest="go",
                        help="Perform changes rather than just printing then")
    parser.add_argument("--dry-run", "-n",
                        action="store_false", dest="go",
                        help="Do not change anything. This is the default")
    parser.add_argument("--color", choices=["always", "never", "auto"],
                        help="When to colorize the output. "
                             "Default: when output is a tty")
    parser.add_argument("--no-color", action="store_false", dest="color",
                        help="Do not colorize output")
    parser.add_argument("--quiet", "-q", action="store_true", dest="quiet",
                        help="Do not produce any output")
    parser.add_argument("pattern")
    parser.add_argument("replacement")
    parser.add_argument("paths", nargs="*")

    parser.set_defaults(
        includes=list(),
        excludes=list(),
        skip_hidden=True,
        backup=False,
        go=False,
        color="auto",
        quiet=False,
        )

    args = parser.parse_args(args=args)
    setup_colors(args)
    repl_main(args)
260171
def options_from_file(args):
    
    logger.debug("updating options from config files")
    updated_from_file = []
    for config_file in CONFIG_FILES:
        logger.debug("updating from: %s", config_file)
        parser = ConfigParser()
        parser.read(config_file)
        try:
            items = parser.items('fades')
        except NoSectionError:
            continue

        for config_key, config_value in items:
            if config_value in ['true', 'false']:
                config_value = config_value == 'true'
            if config_key in MERGEABLE_CONFIGS:
                current_value = getattr(args, config_key, [])
                if current_value is None:
                    current_value = []
                current_value.append(config_value)
                setattr(args, config_key, current_value)
            if not getattr(args, config_key, False) or config_key in updated_from_file:
                # By default all 'store-true' arguments are False. So we only
                # override them if they are False. If they are True means that the
                # user is setting those on the CLI.
                setattr(args, config_key, config_value)
                updated_from_file.append(config_key)
                logger.debug("updating %s to %s from file settings", config_key, config_value)

    return args
688103
def options(self, *args, **kwargs):
        
        self.set_header('Allow', ', '.join(self.ALLOW))
        self.set_status(204)
        self.finish()
1374507
def add_options(cls, parser):
        """"""
        parser.add_option(
            '--putty-select', metavar='errors', default='',
            help='putty select list',
        )
        parser.add_option(
            '--putty-ignore', metavar='errors', default='',
            help='putty ignore list',
        )
        parser.add_option(
            '--putty-no-auto-ignore', action='store_false',
            dest='putty_auto_ignore', default=False,
            help=(' (default) do not auto ignore lines matching '
                  '# flake8: disable=<code>,<code>'),
        )
        parser.add_option(
            '--putty-auto-ignore', action='store_true',
            dest='putty_auto_ignore', default=False,
            help=('auto ignore lines matching '
                  '# flake8: disable=<code>,<code>'),
        )
        parser.config_options.append('putty-select')
        parser.config_options.append('putty-ignore')
        parser.config_options.append('putty-auto-ignore')
835432
def execute(self):
        
        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        parser = NewOptionParser(prog=self.prog_name,
                             usage=self.usage_info,
#                             version=self.get_version(),
                             formatter = NewFormatter(),
                             add_help_option = False,
                             option_list=self.option_list)

        options, args = parser.parse_args(self.argv)
        self.options = options
        if len(args) == 0:
            self.message("You should give at least one package name.", 'error')
            return

        subcommand = args[0]

        self.handle(args[1:], self.options, self.global_options, subcommand)
1204172
def add_command_line_options(cls, parser):
        """"""
        if "add_argument" in dir(parser):
            return cls.add_command_line_options_argparse(parser)
        else:
            return cls.add_command_line_options_optparse(parser)
228137
def handle(self, **options):
        
        super(Command, self).handle(**options)
        return "{} static file{} copied.".format(
            self.num_copied_files,
            '' if self.num_copied_files == 1 else 's')
467508
def handle_basic_executor_options(options, parser):
    """"""
    # setup logging
    logLevel = logging.INFO
    if options.debug:
        logLevel = logging.DEBUG
    elif options.quiet:
        logLevel = logging.WARNING
    util.setup_logging(level=logLevel)
816819
def run_from_argv(self, prog, subcommand, global_options, argv):
        
        self.prog_name = prog
        if self.skip_options:
            parser = NewOptionParser(prog=self.prog_name,
                     usage=self.usage(subcommand),
                    version='',
                    formatter = NewFormatter(),
                     add_help_option = False,
                     option_list=self.option_list)
        else:
            parser = self.create_parser(prog, subcommand)
        options, args = parser.parse_args(argv)
        self.execute(args, options, global_options)
1245374
function execute(args) {
    try {
        const currentOptions = options.parse(args)
        return executeOptions(currentOptions)
    } catch (error) {
        console.error(error.message)
        return 1
    }
}
1219987
def handle_options
      options.rakelib = ['rakelib']
      options.trace_output = $stderr

      OptionParser.new do |opts|
        opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..."
        opts.separator ""
        opts.separator "Options are ..."

        opts.on_tail("-h", "--help", "-H", "Display this help message.") do
          puts opts
          exit
        end

        standard_rake_options.each { |args| opts.on(*args) }
        opts.environment('RAKEOPT')
      end.parse!
    end
1232916
def _call_cmd_line(self):
        """"""
        try:
            logging.info("Calling Popen with: {}".format(self.args))
            p = Popen(self.args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        except OSError:
            raise(RuntimeError("No such command found in PATH"))

        # Calling this command with newline as stdin as the
        # iCommnads hangs waiting for user input if the password
        # has not been set or has timed out.
        self.stdout, self.stderr = p.communicate("\n".encode())
        self.stdout = self.stdout.decode("utf-8")
        self.stderr = self.stderr.decode("utf-8")
        self.returncode = p.returncode
576308
def handle_option(self, opt):
        """"""
        self.options.append(opt)
        log.debug('options: %s', self.options)
543630
function setOptions(opts) {
  opts = opts || {};

  if ((!opts.src || !opts.dest) && opts._.length < 2) {
    var msg = 'please let me know your "src" and "dest" path. \n--> run "assets-bundler -h" for more info.';
    console.error(msg);
    if (opts.parent === 'cmd') process.exit(1);
  }

  if (!opts.src && opts._.length >= 2) opts.src = opts._[0];
  if (!opts.dest && opts._.length >= 2) opts.dest = opts._[1];

  opts.env = opts.env || process.env.NODE_ENV || defaultEnv;
  if (opts.env === 'dev') opts.env = 'development';
  if (opts.env === 'prod') opts.env = 'production';

  debug('options', opts);
  return opts;
}
804153
def cmd(self, args=None, interact=True):
        """"""
        if args is None:
            parsed_args = arguments.parse_args()
        else:
            parsed_args = arguments.parse_args(args)
        self.exit_code = 0
        with self.handling_exceptions():
            self.use_args(parsed_args, interact, original_args=args)
        self.exit_on_error()
592153
function setOptions(command, query) {
  var count, opts;

  command = commands[command];
  if (!command) {
    return;
  }

  opts = {};
  count = Object.keys(query).length;

  [options.common].concat(command.options).some(function someTypes(options) {
    if (!options) {
      return;
    }
    Object.keys(options).some(function someOptions(key) {
      var valid = options[key].valid;

      if (key in query) {
        if (options[key].bool) {
          opts[options[key].name] = !reBool.test(query[key]);
        } else if (!valid || (valid && valid.test(query[key]))) {
          opts[options[key].name] = decodeURIComponent(query[key]);
        }
        count -= 1;
      }

      return count === 0;
    });

    return count === 0;
  });

  return opts;
}
938740
function resetOptions(grunt, parsedOptions){
	for (var i in parsedOptions){
		if (parsedOptions.hasOwnProperty(i) && i != 'argv'){
			grunt.option(i, parsedOptions[i]);
		}
	}
}