传入参数进行初始化
@param {Array} argvs cli 传入的参数列表. 不包括 node [--debug] twei
490527
function init(argvs){
  var args = argvs.slice()
    ;
  
  for(var i = 0, l = args.length; i < l; i++){
    if(args[i].indexOf('-')){
      args.splice.apply(args, [i, 1].concat(restoreAlias(args[i]) || [args[i]]))
      break;
    }
  }
  
  var cmds = argParser(args)
    , flagFn
    
    , cmd = cmds.name
    , param = cmds.param
    , flagsParam = cmds.opts
    , extras = cmds.extras
    ;
  
  for(var opt in cmds.extras){//选项参数表中没有列出的, 都当做微博 api 参数
    param.push(opt.replace(/^--?/, '') + '=' + encodeURIComponent(cmds.extras[opt][0] || ''));
  }
  
  if(flagsParam['-d'] || flagsParam['--debug']){//提升 debug 执行顺序
    argParser.getOptFn('-d')();
    delete flagsParam['-d'];
    delete flagsParam['--debug'];
  }
  
  log('cmds: ' + util.inspect(cmds));
  
  for(var key in flagsParam){
    flagFn = argParser.getOptFn(key);
    if(flagFn){
    
      if(flagFn == argParser.getOptFn('--help')){//命令行其他的参数都传给 --help 处理函数
        flagFn.apply(null, (cmd ? [cmd] : []).concat(param).concat(flagsParam[key]));
        exit();
      }else{
        flagFn.apply(null, flagsParam[key]);
      }
    }
  }
  
  if(!optInfo.shower){
    optInfo.shower = argParser.getOptFn('--shower')();
  }
  
  cmdMap[cmd] ? cmdMap[cmd].apply(null, param) : (function(){help(cmd);exit(1)})();
}
767887
public static void main(String[] argv) throws IOException {
    final File outputDir = new File(argv[0]);

    final Random rand = new Random();
    final double mean1 = 5.0;
    final double mean2 = 7.0;
    final double dev1 = 2.0;
    final double dev2 = 4.0;

    final double[] data1 = new double[100];
    final double[] data2 = new double[100];

    for (int i = 0; i < 100; ++i) {
      data1[i] = rand.nextGaussian() * dev1 + mean1;
      data2[i] = rand.nextGaussian() * dev2 + mean2;
    }

    BoxPlot.builder()
        .addDataset(Dataset.createAdoptingData("A", data1))
        .addDataset(Dataset.createAdoptingData("B", data2))
        .setTitle("A vs B")
        .setXAxis(Axis.xAxis().setLabel("FooCategory").build())
        .setYAxis(Axis.yAxis().setLabel("FooValue").setRange(Range.closed(0.0, 15.0)).build())
        .hideKey()
        .build().renderToEmptyDirectory(outputDir);
  }
782529
function parse(argv) {
  if (Array.isArray(argv)) {
    argv = argv.join(" ");
  }

  var opts = {};
  var paramStr = argv.replace(/(-{1,2}\S+?)\s+((?!-)[\S]+)/g, function(pair){
    var match = pair.match(/-{1,2}(\S+?)\s+((?!-)[\S]+)/);
    var key = match[1], value = match[2];
    try {
      value = JSON.parse(value);
    } catch (error) {}

    val(opts, key, value);
    return '';
  });

  var flags = {};
  var params = paramStr.split(' ').filter(function(param) {
    if (param == '') return false;
    if (param.search(/^-/) == 0) {
      param = param.replace(/^-{1,2}/, '');
      val(flags, param, true);
      return false;
    }
    return true;

  }).map(function(str) {
    try {
      return JSON.parse(str);
    } catch(error) {
      return str;
    }
  });

  return { opts: opts, params: params, flags: flags };
}
29376
static void parseArgs(String[] args) {
    int i = 0;
    while (true) {
      if (i >= args.length) {
        break;
      }

      String s = args[i];
      if (s.equals("-h") ||
              s.equals("help") ||
              s.equals("-help") ||
              s.equals("--help")) {
        usage();
      }
      else if (s.equals("-zk")) {
        i++; if (i >= args.length) { usage(); }
        g_zk = args[i];
      }
      else if (s.equals("-zkroot")) {
        i++; if (i >= args.length) { usage(); }
        g_zkroot = args[i];
      }
      else if (s.equals("-n") ||
              s.equals("-nodes")) {
        i++; if (i >= args.length) { usage(); }
        g_numNodes = Integer.parseInt(args[i]);
      }
      else if (s.equals("-timeout")) {
        i++; if (i >= args.length) { usage(); }
        g_cloudFormationTimeoutSeconds = Integer.parseInt(args[i]);
      }
      else if (s.equals("-start")) {
        g_start = true;
      }
      else if (s.equals("-wait")) {
        g_wait = true;
      }
      else {
        error("Unrecognized option " + s);
      }

      i++;
    }

    // Check for mandatory arguments.
    if (g_start) {
      if (g_numNodes < 1) {
        error("Number of H2O nodes must be greater than 0 (must specify -n)");
      }
    }

    if (g_wait) {
      if (g_numNodes != -1) {
        error("-nodes option may not be combined with -wait option");
      }
    }

    if (!g_start && !g_wait) {
      error("-start or -wait must be specified");
    }
  }
524146
public static void main(String[] argv) throws Exception {
    SingleThreadBlockingQpsBenchmark bench = new SingleThreadBlockingQpsBenchmark();
    bench.setup();
    for  (int i = 0; i < 10000; i++) {
      bench.blockingUnary();
    }
    Thread.sleep(30000);
    bench.teardown();
    System.exit(0);
  }
125401
function tail (argv, callback) {
  if (!argv[2]) {
    console.error('url is required')
    console.error('Usage : tail <url>')
    process.exit(-1)
  }
  var uri = argv[2]
  var wss = 'wss://' + uri.split('/')[2] + '/'

  var s = new ws(wss, {
    origin: 'http://websocket.org'
  })

  s.on('open', function open () {
    s.send('sub ' + uri)
  })

  s.on('close', function close () {
    console.log('disconnected')
  })

  s.on('message', function message (data, flags) {
    var a = data.split(' ')
    if (a.length && a[0] === 'pub') {
      util.get(a[1], function (err, res) {
        if (err) {
          console.error('Error : ' + err)
        } else {
          console.log(res)
        }
      })
    }
  })
}
885933
public static void main(String[] args) {
        String modelFile = "";
        String outputFile = "";
        int numberOfRows = 0;
        try {
            modelFile = args[0];
            outputFile = args[1];
            numberOfRows = Integer.valueOf(args[2]);
        } catch (IndexOutOfBoundsException | NumberFormatException e) {
            System.out.println("ERROR! Invalid command line arguments, expecting: <scxml model file> "
                    + "<desired csv output file> <desired number of output rows>");
            return;
        }

        FileInputStream model = null;
        try {
            model = new FileInputStream(modelFile);
        } catch (FileNotFoundException e) {
            System.out.println("ERROR! Model file not found");
            return;
        }

        SCXMLEngine engine = new SCXMLEngine();
        engine.setModelByInputFileStream(model);
        engine.setBootstrapMin(5);

        DataConsumer consumer = new DataConsumer();
        CSVFileWriter writer;
        try {
            writer = new CSVFileWriter(outputFile);
        } catch (IOException e) {
            System.out.println("ERROR! Can not write to output csv file");
            return;
        }
        consumer.addDataWriter(writer);

        DefaultDistributor dist = new DefaultDistributor();
        dist.setThreadCount(5);
        dist.setMaxNumberOfLines(numberOfRows);
        dist.setDataConsumer(consumer);

        engine.process(dist);
        writer.closeCSVFile();

        System.out.println("COMPLETE!");
    }
519329
private static void trueMain(String[] argv) throws Exception {
    if (argv.length != 1) {
      System.err.println("Please provide a params file as the sole command line argument");
      System.exit(-1);
    }
    final Parameters params = Parameters.loadSerifStyle(new File(argv[0]));

    final File outputDirectory = params.getCreatableDirectory("outputDirectory");
    final File corpusRoot = params.getExistingDirectory("corpusRoot");
    final int memory = params.getPositiveInteger("memoryInMB");
    final boolean storeDocs = params.getBoolean("storeDocs");
    final Predicate<File> fileFilter = getFileFilter(params);
    final IndriFileProcessor indriFileProcessor = params.getParameterInitializedObject(
        "indriFileProcessorClass", IndriFileProcessor.class);

    log.info("Building index for corpus {} format to {} using processor {}",
        corpusRoot, outputDirectory, indriFileProcessor.getClass().getName());

    final IndexEnvironment env = setupIndexer(outputDirectory, memory, storeDocs);

    recursiveIndex(corpusRoot, env, indriFileProcessor,
        fileFilter);
    log.info("Indexed {} documents", env.documentsIndexed());
    env.close();
    log.info("Index complete");
  }
197957
function Args() {
    if (argv._.length >= 1) {
        try {
            // Attempt to parse 1st argument as JSON string
            _.extend(this, JSON.parse(argv._[0]));
        } catch (err) {
            // Pass, we must be in the console so don't worry about it
        }
    }
}
272870
function collectExtraArgs(argv) {
    const parsed = parseArgv(argv, {
      configuration: {
        'boolean-negation': false,
        'camel-case-expansion': false,
        'dot-notation': false,
        'parse-numbers': false,
        'duplicate-arguments-array': false
      }
    });

    const passthrough = _.chain(parsed)
      .omitBy((_value, key) => blacklistedArgs.has(key))
      .entries()
      .map(([key, value]) => {
        return value === true ? `--${key}` : `--${key} ${value}`;
      })
      .concat(parsed['_'])
      .value();

    return passthrough;
  }
729535
function run(argv, options, loader) {
  debug('argv', argv, 'options', options);

  if (options.help || options.h) {
    return loader.printUsage('env');
  }

  var selector = options._; // the argv, stripped of the flags (both -- and -)

  installPaths(function(er, paths) {
    var execPaths = resolvePaths(paths);

    execPaths['slc-npm'] = slcNpmPath(execPaths.slc);
    execPaths['node-npm'] = nodeNpmPath(execPaths.node);

    var env = {
      cwd: process.cwd(),
      paths: {
        link: paths,
        exec: execPaths
      },
      versions: process.versions,
      platform: process.platform,
      config: process.config,
      // redundant with .paths: execPath: process.execPath,
      features: process.features
    };
    try {
      env = selectProperties(selector, env);//XXX argv--> includes options?
    } catch (er) {
      return loader.error(er.message);
    }
    console.log(env);
  });
}
392870
function CliStripNodeJake(argv)
{
    const nodeRegex = /^(.*)\/node$/;
    const yakeRegex = /(.*)yake(.*)$/;
    const taskFileRegex = /\.\/(.*)\.js(\s*)$/;
    // let argsNoNode;
    let argNoNodeNoYake;
    /**
     * Strip ['....node', '....yake'] or ['....yake'] or [./<....>.js] from the start of the argv array
     */

    if (argv[0].match(nodeRegex))
    {
        argNoNodeNoYake = argv.slice(1);
        if (argv[1].match(nodeRegex))
        {
            argNoNodeNoYake = argv.slice(2);
        }
    }
    else if (argv[0].match(yakeRegex))
    {
        argNoNodeNoYake = argv.slice(1);
    }
    else if (argv[0].match(taskFileRegex))
    {
        argNoNodeNoYake = argv.slice(1);
    }
    else
    {
        argNoNodeNoYake = argv.slice();
    }

    return argNoNodeNoYake;
}
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);
  }
}
50022
private void checkArgs(final String[] argv) throws DevFailed {
        if (argv.length < 1) {
            throw DevFailedUtils.newDevFailed(INIT_ERROR, getUsage());
        }
        instanceName = argv[0];
        useDb = true;
        DatabaseFactory.setUseDb(true);
        List<String> noDbDevices = new ArrayList<String>();
        for (int i = 1; i < argv.length; i++) {
            final String arg = argv[i];
            if (arg.startsWith("-h")) { // trace instance name
                System.out.println("instance list for server " + execName + ": "
                        + Arrays.toString(DatabaseFactory.getDatabase().getInstanceNameList(execName)));
            } else if (arg.startsWith("-v")) { // logging level
                try {
                    final int level = Integer.parseInt(arg.substring(arg.lastIndexOf('v') + 1));
                    LoggingManager.getInstance().setLoggingLevel(level,
                            tangoClasses.values().toArray(new Class<?>[0]));
                } catch (final NumberFormatException e) {
                    throw DevFailedUtils.newDevFailed("Logging level error. Must be a number");
                }
            } else if (arg.startsWith("-dlist")) {
                noDbDevices = configureNoDB(argv, i);
                useDb = false;
            } else if (arg.startsWith("-file")) {
                configureNoDBFile(argv, arg, noDbDevices);
                useDb = false;
            }
        }
    }
562983
public static void main(String[] argv) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		
			new ParticleEditor();
		} catch (Exception e) {
			Log.error(e);
		}
	}
182360
def handle_argv(self, prog_name, argv):
        
        options, args = self.parse_options(prog_name, argv)
        return self.run(*args, **vars(options))
933465
@SuppressWarnings("PMD.ExceptionAsFlowControl")
    public static void main(String... args) {
        OptionsAndArgs options;
        try {
            options = new OptionsAndArgs(CommandDispatcher.getAvailableCommands(),args);
            VirtualMachineHandler vmHandler = new VirtualMachineHandler(options);
            CommandDispatcher dispatcher = new CommandDispatcher(options);

            // Attach a VirtualMachine to a given PID (if PID is given)
            Object vm = options.needsVm() ? vmHandler.attachVirtualMachine() : null;

            // Dispatch command
            int exitCode = 0;
            try {
                exitCode = dispatcher.dispatchCommand(vm,vmHandler);
            } catch (InvocationTargetException e) {
                throw new ProcessingException("InvocationTargetException",e,options);
            } catch (NoSuchMethodException e) {
                throw new ProcessingException("Internal: NoSuchMethod",e,options);
            } catch (IllegalAccessException e) {
                throw new ProcessingException("IllegalAccess",e,options);
            } finally {
                if (vm != null) {
                    vmHandler.detachAgent(vm);
                }
            }
            System.exit(exitCode);

        } catch (IllegalArgumentException exp) {
            System.err.println("Error: " + exp.getMessage() + "\n");
            CommandDispatcher.printHelp();
            System.exit(1);
        } catch (ProcessingException exp) {
            exp.printErrorMessage();
            System.exit(1);
        }
    }