This main function implements the CLI
171119
def main():
    """""""
    parser = argparse.ArgumentParser(description='Do something awesome')
    parser.add_argument('input_file', nargs=1,
                        type=argparse.FileType('r'))
    parser.add_argument('-o', '--outfile', nargs='?',
                        type=argparse.FileType('w'), default=sys.stdout)
    args = parser.parse_args()

    print(json_to_csv(args.input_file[0].read()), file=args.outfile)
291090
def main(argv=None):
    
    # Get command line arguments, validate them, and normalize them
    opts = cmdparse.parse_args(argv)
    assert validate_opts.validate(opts)
    opts = normalize_opts.normalize(opts)

    if opts.verbose:
        # Update client: print input and output directories
        messages.print_input_output(opts)

    file_paths = fileparse.get_file_list(opts)
    assert validate_files.validate(file_paths, opts)

    if opts.verbose and opts.is_dir:
        # Update client: print files that will be parsed
        messages.print_files(opts, file_paths)

    # For now, only using default GitHub Markdown for parsing
    # Collect tag/anchor combinations
    collector = make_github_markdown_collector(opts)
    anchors, duplicate_tags = collector.collect(file_paths)
    assert validate_anchors.validate(anchors, duplicate_tags, opts)

    # Write files using previously found AnchorHub tags and generated anchors
    writer = make_github_markdown_writer(opts)
    counter = writer.write(file_paths, anchors, opts)

    if opts.verbose:
        if opts.is_dir:
            # Update client: print files that had modifications
            messages.print_modified_files(opts, anchors)
        # Print summary statistics
        messages.print_summary_stats(counter)
423727
def main():
    ''''''
    import getopt

    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hv', ['help', 'version'])
    except getopt.GetoptError as err:
        sys.stderr.write('Error: %s\n' % err)
        exit(2)

    for opt, _ in opts:
        if opt in ['-h', '--help']:
            show_usage()
            exit()
        elif opt in ['-v', '--version']:
            show_version()
            exit()

    if len(args) != 2:
        show_usage()
        exit(1)

    infile, outfile = args
    if infile == outfile:
        sys.stderr.write('Error: outfile must differ from infile\n')
        exit(3)

    reverse_file(infile, outfile)
    sys.stdout.write('Successfully written to %s\n' % outfile)
507634
def main(cls):
        
        chain = cls.create()
        args = chain._run_argparser(sys.argv[1:])
        chain._run_chain(sys.stdout, args.dry_run)
        chain._finalize(args.dry_run)
530260
function main (processArgv, conf) {

  // CLI input
  var opts = getOpts(processArgv);
  var argv = opts.argv;

  // Update notifier
  if (!argv["no-notifier"]) {
    checkUpdate();
  }

  // Convert options "--help" and "-h" into command "help"
  if (argv.help) {
    processArgv = transformHelpArgs(processArgv);
    // Regenerate opts from newly forged process.argv
    opts = getOpts(processArgv);
    argv = opts.argv;
  }

  // "--version"
  if (argv.version) {
    showVersion();
  }

  var commandName = argv._[0];

  // Demand command name
  if (!commandName) {
    console.error("No command specified");
    opts.showHelp();
    process.exit(127);
  }

  // Load command module
  var command = commands.load(commandName);

  // Demand valid command
  if (!command) {
    console.error("Unknown command: " + commandName);
    opts.showHelp();
    process.exit(127);
  }

  process.on("exit", function () {
    ttys.stdin.end();
  });

  // Configure opts and run command (inside a domain to catch any error)
  commands.run(command, opts, conf).then(ok, fail);

  function ok () {
    process.exit(0);
  }

  function fail (e) {
    if (e.code === "EINTERRUPT") {
      process.exit(127);
    } else {
      console.error("%s", e);
      if (process.env.DEBUG) {
        throw e;
      }
      process.exit(1);
    }
  }
}
773307
def main():  # pragma: nocover
    
    p = argparse.ArgumentParser()
    p.add_argument(
        'directory',
        help="Directory to check"
    )
    p.add_argument(
        '--verbose', '-v', action='store_true',
        help="increase verbosity"
    )
    args = p.parse_args()

    import sys
    _changed = changed(sys.argv[1], args=args)
    sys.exit(_changed)
876711
def main():
    
    if '-h' in sys.argv:
        print(main.__doc__)
        sys.exit()
    file=sys.argv[1]
    f=open(file,'r')
    Input=f.readlines()
    f.close()
    out=open(file,'w')
    for line in Input:
        out.write(line)
    out.close()
1025967
public function main()
    {
        $this->out('Welcome to the Proffer shell.');
        $this->out('This shell can be used to regenerate thumbnails and cleanup unlinked images.');
        $this->hr();
        $this->out($this->OptionParser->help());
    }
1335519
def main():
    """"""
    args = parse_arguments()
    print(args)
    print("action" + args.action)
    print("pid" + args.pid)
    print("directory" + args.directory)
    print("fileprefix" + args.fileprefix)
1238054
def main(self):
        
        parser = self.init_parser()
        if len(sys.argv) < 2:
            parser.print_usage()
            sys.exit(0)

        self.args = parser.parse_args()
        self.roca.args.flatten = self.args.flatten
        self.roca.args.indent = self.args.indent

        if self.args.debug:
            coloredlogs.install(level=logging.DEBUG)
            self.roca.args.debug = True

        self.work()
319564
def main():
    

    init_logger()
    args = _parse_cli_args()

    if args.u:
        enter_api_key()
        return

    if args.O == GEVENT:
        args.O = _gevent_patch()

    set_image_size_mode(args.s)
    photoset_id = args.g
    global directory
    directory = args.d if args.d else photoset_id

    read_config()
    photos = get_photos_info(photoset_id)
    create_dir(directory)

    if args.O == SINGLE_PROCESS:
        single_download_photos(photos)
    elif args.O == GEVENT:
        event_download_photos(photos)
    elif args.O == MULTITHREAD:
        multithread_download_photos(photos)
    else:
        logger.error('Unknown Error')
1115257
def main():
    
    parser = build_parser()

    args = parser.parse_args()
    flags = re.LOCALE

    if args.dot_all:
        flags |= re.DOTALL

    if args.ignorecase:
        flags |= re.IGNORECASE

    if args.unicode:
        flags |= re.UNICODE

    if args.multiline:
        flags |= re.MULTILINE

    exclude_path_flags = re.UNICODE | re.LOCALE
    exclude_path_regexes = [ re.compile(pattern, exclude_path_flags)
                             for pattern in args.exclude_path_patterns ]

    pattern = re.escape(args.pattern) if args.escape else args.pattern

    try:
        search_manager = SearchManager(regex=re.compile(pattern, flags),
                                       number_processes=args.number_processes,
                                       search_hidden=args.search_hidden,
                                       follow_links=args.follow_links,
                                       search_binary=args.search_binary,
                                       use_ansi_colors=args.use_ansi_colors,
                                       print_stats=args.print_stats,
                                       exclude_path_regexes=exclude_path_regexes,
                                       command_strings=args.command_strings)

        search_manager.enqueue_directory(args.directory)
        search_manager.process_queue()

    except (KeyboardInterruptError, KeyboardInterrupt):
        sys.stdout.write('\n')
        exit(1)
88382
def main(argv=None):
    
    # Parse arguments
    parser = argparse.ArgumentParser(
        prog="pelix.shell.console",
        parents=[make_common_parser()],
        description="Pelix Shell Console",
    )

    # Parse arguments
    args = parser.parse_args(argv)

    # Handle arguments
    init = handle_common_arguments(args)

    # Set the initial bundles
    bundles = [
        "pelix.ipopo.core",
        "pelix.shell.core",
        "pelix.shell.ipopo",
        "pelix.shell.completion.pelix",
        "pelix.shell.completion.ipopo",
        "pelix.shell.console",
    ]
    bundles.extend(init.bundles)

    # Use the utility method to create, run and delete the framework
    framework = pelix.create_framework(
        remove_duplicates(bundles), init.properties
    )
    framework.start()

    # Instantiate components
    init.instantiate_components(framework.get_bundle_context())

    try:
        framework.wait_for_stop()
    except KeyboardInterrupt:
        framework.stop()
618883
def main(self, argv=None, exit=True):
        
        return CommandRecipe(self).main(argv, exit)
559891
function main(args, callback) {

  var opts = {};
  Object.keys(options).forEach(key => {
    var opt = options[key];
    if (opt.aliases)
      (opts.alias || (opts.alias = {}))[key] = opt.aliases;
    if (opt.default !== undefined)
      (opts.default || (opts.default = {}))[key] = opt.default;
    if (opt.type === "string")
      (opts.string || (opts.string = [])).push(key);
    else if (opt.type === "boolean")
      (opts.boolean || (opts.boolean = [])).push(key);
  });

  var argv = minimist(args, opts);

  var files = argv._;
  var configFile;

  // prefer specified config file
  if (argv.config)
    configFile = argv.config;

  // otherwise check entry file directory
  else if (files.length)
    if (!fs.existsSync(configFile = path.join(path.dirname(files[0]), "asconfig.json"))) {
      configFile = undefined;
      if (!fs.existsSync(configFile = path.join(path.dirname(files[0]), "tsconfig.json")))
        configFile = undefined;
    }

  // load config file
  if (configFile) {
    try {
      var config = JSON.parse(fs.readFileSync(configFile, "utf8"));
      if (config.assembly)
        config = config.assembly;
      if (config.entryFile) {
        if (!files.length) // prefer command line
          files = [ config.entryFile ];
        delete config.entryFile;
      }
      Object.keys(config).forEach(key => {
        if (options[key] && key !== "config") // prefer command line
          if (options[key].isPath)
            argv[key] = path.isAbsolute(config[key]) ? config[key] : path.join(path.dirname(configFile), config[key]);
          else
            argv[key] = config[key];
      });
    } catch (e) {
      if (!argv.quiet)
        process.stderr.write(chalk.red("\nFailed to load config file: " + e.message + "\n"));
      return callback(EFAILURE);
    }
  }

  // print usage information if requested or no input files have been provided
  if (argv.help || files.length !== 1) {
    (argv.help ? process.stdout : process.stderr).write([
      "Version " + pkg.version + (isDev ? "-dev" + (isOut ? " (out)" : "") : ""),
      "Syntax: "+ chalk.reset.cyan.bold("asc") + " [options] entryFile",
      "",
      chalk.reset.white.bold("Options:"),
      ""
    ].concat(Object.keys(options).map(key => {
      var opt = options[key];
      var cmd = " --" + key;
      if (opt.aliases && opt.aliases.length && opt.aliases[0].length === 1)
        cmd += ", -" + opt.aliases[0];
      while (cmd.length < 18)
        cmd += " ";
      return cmd + "  " + opt.desc.replace(/\n/g, "\n                    ") + "\n";
    })).join("\n").replace(/\[default\]/g, chalk.gray("[default]")));
    return callback(argv.help ? ESUCCESS : EUSAGE);
  }

  // compile to a Binaryen module
  var wasmModule = Compiler.compileFile(files[0], {
    silent: !!argv.quiet,
    target: argv.target,
    noTreeShaking: !!argv.noTreeShaking,
    noImplicitConversion: !!argv.noImplicitConversion,
    noRuntime: !!argv.noRuntime,
    exportRuntime: Array.isArray(argv.exportRuntime) ? argv.exportRuntime
                 : typeof argv.exportRuntime === "string" ? [ argv.exportRuntime ]
                 : undefined
  });

  // bail out if that didn't work
  if (!wasmModule)
    return callback(EFAILURE);

  // from this point on the module must be disposed (finish does this implicitly)

  // optimize the Binaryen module if requested
  if (argv.optimize)
    wasmModule.optimize();

  // validate the Binaryen module if requested
  if (argv.validate) {
    var result = wasmModule.validate(); // FIXME: this always prints to console on error
    if (!result) {
      if (!argv.quiet)
        process.stderr.write(chalk.red("\nValidation failed. See above for details.\n"));
      return finish(Error("validation failed"));
    }
  }

  // default to text format if --outFile references a .wast, .wat or .js and --textFormat isn't specified
  if (argv.outFile && !argv.textFormat) {
    if (/\.wast$/.test(argv.outFile))
      argv.textFormat = "sexpr";
    else if (/\.wat$/.test(argv.outFile))
      argv.textFormat = "linear";
    else if (/\.js$/.test(argv.outfile))
      argv.textFormat = "asmjs";
  }

  // emit to --outFile if specified, otherwise print to stdout
  var output = argv.outFile ? fs.createWriteStream(argv.outFile) : process.stdout;

  // emit text format (textFormat is requested but no textFile has been specified) + asm.js (if applicable)
  if ((argv.textFormat !== undefined || output.isTTY) && !argv.textFile) {
    if (argv.textFormat === "asmjs" || /\.js$/.test(argv.outFile))
      writeAsmjs(wasmModule, output, finish);
    else
      writeText(wasmModule, argv.textFormat, output, maybeWriteAsmjs);

  // emit a binary + text format (if specified) + asm.js (if specified)
  } else
    writeBinary(wasmModule, output, maybeWriteText);

  function maybeWriteText(err) {
    if (err || !argv.textFile)
      return finish(err);
    if (argv.textFormat === "asmjs" || (!argv.textFormat && /\.js$/.test(argv.textFile)))
      writeAsmjs(wasmModule, fs.createWriteStream(argv.textFile), finish);
    else
      writeText(wasmModule, argv.textFormat || /\.wat$/.test(argv.textFile) && "linear" || "sexpr", fs.createWriteStream(argv.textFile), maybeWriteAsmjs);
  }

  function maybeWriteAsmjs(err) {
    if (err || !argv.asmjsFile)
      return finish(err);
    writeAsmjs(wasmModule, fs.createWriteStream(argv.asmjsFile), finish);
  }

  function finish(err) {
    wasmModule.dispose();
    return callback(err ? EFAILURE : ESUCCESS);
  }
}
21059
def main():
    
    plugins = DefaultPluginManager()
    plugins.load_plugins()

    parser, _ = create_argparser()
    # add the updater protocol options to the CLI:
    for kls in updater_classes():
        kls.register_arguments(parser)

    for kls in detector_classes():
        kls.register_arguments(parser)

    # add the plugin options to the CLI:
    from os import environ
    plugins.options(parser, environ)

    args = parser.parse_args()

    if args.debug:
        args.verbose_count = 5  # some high number

    log_level = max(int(logging.WARNING / 10) - args.verbose_count, 0) * 10
    # print(log_level)
    logging.basicConfig(level=log_level, format="%(levelname)s %(message)s")
    # logging.debug("args %r", args)

    if args.version:
        from . import __version__
        print("dyndnsc %s" % __version__)  # noqa
        return 0

    # silence 'requests' logging
    requests_log = logging.getLogger("requests")
    requests_log.setLevel(logging.WARNING)

    logging.debug(parser)
    cfg = get_configuration(args.config)

    if args.listpresets:
        list_presets(cfg)
        return 0

    if args.config:
        collected_configs = collect_config(cfg)
    else:
        parsed_args = parse_cmdline_args(args, updater_classes().union(detector_classes()))
        logging.debug("parsed_args %r", parsed_args)

        collected_configs = {
            "cmdline": {
                "interval": int(args.sleeptime)
            }
        }
        collected_configs["cmdline"].update(parsed_args)

    plugins.configure(args)
    plugins.initialize()

    logging.debug("collected_configs: %r", collected_configs)
    dyndnsclients = []
    for thisconfig in collected_configs:
        logging.debug("Initializing client for '%s'", thisconfig)
        # done with options, bring on the dancing girls
        dyndnsclient = getDynDnsClientForConfig(
            collected_configs[thisconfig], plugins=plugins)
        if dyndnsclient is None:
            return 1
        # do an initial synchronization, before going into endless loop:
        dyndnsclient.sync()
        dyndnsclients.append(dyndnsclient)

    run_forever_callable = partial(run_forever, dyndnsclients)

    if args.daemon:
        import daemonocle
        daemon = daemonocle.Daemon(worker=run_forever_callable)
        daemon.do_action("start")
        args.loop = True

    if args.loop:
        run_forever_callable()

    return 0
297592
def main(arguments=None):
    
    # setup the command-line util settings

    dev_flag = False

    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="DEBUG",
        options_first=False,
        projectName="rockAtlas"
    )
    arguments, settings, log, dbConn = su.setup()

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if varname == "import":
            varname = "iimport"
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    ## START LOGGING ##
    startTime = times.get_now_sql_datetime()
    log.info(
        '--- STARTING TO RUN THE cl_utils.py AT %s' %
        (startTime,))

    if init:
        from os.path import expanduser
        home = expanduser("~")
        filepath = home + "/.config/rockAtlas/rockAtlas.yaml"
        try:
            cmd = """open %(filepath)s""" % locals()
            p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
        except:
            pass
        try:
            cmd = """start %(filepath)s""" % locals()
            p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
        except:
            pass

    # CALL FUNCTIONS/OBJECTS
    if bookkeeping:
        from rockAtlas.bookkeeping import bookkeeper
        bk = bookkeeper(
            log=log,
            settings=settings,
            fullUpdate=fullFlag
        )
        bk.clean_all()

    if astorb:
        from rockAtlas.orbital_elements import astorb
        oe = astorb(
            log=log,
            settings=settings
        )
        oe.refresh()

    if pyephem:

        from rockAtlas.positions import pyephemPositions
        pyeph = pyephemPositions(
            log=log,
            settings=settings,
            dev_flag=dev_flag
        )
        pyeph.get(singleSnapshot=oneFlag)

    if orbfit:
        from rockAtlas.positions import orbfitPositions
        oe = orbfitPositions(
            log=log,
            settings=settings,
            dev_flag=dev_flag
        )
        oe.get(singleExposure=oneFlag)

    if cache:
        from rockAtlas.phot import download
        data = download(
            log=log,
            settings=settings,
            dev_flag=dev_flag
        )
        data.get(days=days)

    if dophot:
        from rockAtlas.phot import dophotMatch
        dp = dophotMatch(
            log=log,
            settings=settings
        )
        dp.get()

    if cycle:
        from rockAtlas.phot import download
        from rockAtlas.positions import pyephemPositions
        from rockAtlas.positions import orbfitPositions
        from rockAtlas.phot import dophotMatch
        from fundamentals.mysql import readquery

        # INITIAL ACTIONS
        # SETUP ALL DATABASE CONNECTIONS
        from rockAtlas import database
        db = database(
            log=log,
            settings=settings
        )
        dbConns, dbVersions = db.connect()
        atlas3DbConn = dbConns["atlas3"]
        atlas4DbConn = dbConns["atlas4"]
        atlasMoversDBConn = dbConns["atlasMovers"]

        while True:

            if dev_flag:
                o = " and dev_flag = 1"
            else:
                o = " "

            sqlQuery = u"""
                select distinct floor(mjd) from (
select mjd from atlas_exposures where dophot_match = 0 %(o)s
union all
select mjd from day_tracker where processed = 0 %(o)s) as a;
            """ % locals()
            rows = readquery(
                log=log,
                sqlQuery=sqlQuery,
                dbConn=atlasMoversDBConn,
                quiet=False
            )

            if len(rows) == 0:
                if dev_flag:
                    print "Processing of the ATLAS development dataset is now complete and up to date"
                else:
                    print "Processing of ATLAS data is now complete and up to date"
                break

            start_time = time.time()

            data = download(
                log=log,
                settings=settings,
                dev_flag=dev_flag
            )
            data.get(days=days)

            print "%d seconds to download ATLAS cache of %s days\n" % (time.time() - start_time, days)
            start_time = time.time()

            pyeph = pyephemPositions(
                log=log,
                settings=settings,
                dev_flag=dev_flag
            )
            pyeph.get()

            print "%d seconds to generate pyephem snapshots\n" % (time.time() - start_time,)
            start_time = time.time()

            oe = orbfitPositions(
                log=log,
                settings=settings,
                dev_flag=dev_flag
            )
            oe.get()

            print "%d seconds to generate orbfit positions\n" % (time.time() - start_time,)
            start_time = time.time()

            dp = dophotMatch(
                log=log,
                settings=settings
            )
            dp.get()

            print "%d seconds to extract dophot measurements\n" % (time.time() - start_time,)
            start_time = time.time()

    if "dbConn" in locals() and dbConn:
        dbConn.commit()
        dbConn.close()
    ## FINISH LOGGING ##
    endTime = times.get_now_sql_datetime()
    runningTime = times.calculate_time_difference(startTime, endTime)
    log.info('-- FINISHED ATTEMPT TO RUN THE cl_utils.py AT %s (RUNTIME: %s) --' %
             (endTime, runningTime, ))

    return