org.apache.commons.cli.GnuParser Java Examples

The following examples show how to use org.apache.commons.cli.GnuParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: App.java    From mysql_perf_analyzer with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	App myServer = new App();
	CommandLineParser parser = new GnuParser();
	Options options = getAvaliableCommandLineOptions();
	System.out
			.println(new Date()
					+ " Usage: java -classpath ... com.yahoo.dba.tools.myperfserver.App -f config_file_path -j jettyhome "
					+ "-p port -c webcontextroot -k workingDir -l logpath -w war_file");
	readOptionsFromCommandLine(args, parser, options, myServer);
	System.setProperty("logPath", myServer.getLogDirectoryPath());
	PID_FILE = myServer.getWarFile().substring(0,
			myServer.getWarFile().indexOf('.'))
			+ ".pid";
	checksRunningOfAnotherServerInstance();
	//for https, we have to use https for jQuery
	System.setProperty("url_protocl", myServer.useHttps?"https":"http");
	runServer(myServer);
}
 
Example #2
Source File: TestTFileSeek.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #3
Source File: NetezzaManager.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 6 votes vote down vote up
private void handleNetezzaImportExtraArgs(ImportJobContext context)
    throws ParseException {

  SqoopOptions opts = context.getOptions();
  Configuration conf = opts.getConf();

  String[] extraArgs = opts.getExtraArgs();


  conf.setBoolean(NETEZZA_DATASLICE_ALIGNED_ACCESS_OPT, false);

  if (extraArgs != null && extraArgs.length > 0
      && ConfigurationHelper.getConfNumMaps(conf) > 1) {
    RelatedOptions netezzaOpts = getNetezzaExtraOpts();
    CommandLine cmdLine = new GnuParser().parse(netezzaOpts, extraArgs, true);
    if (cmdLine.hasOption(NETEZZA_DATASLICE_ALIGNED_ACCESS_LONG_ARG)) {
      conf.setBoolean(NETEZZA_DATASLICE_ALIGNED_ACCESS_OPT, true);
      context.setInputFormat(NetezzaDataDrivenDBInputFormat.class);
    }
  }

}
 
Example #4
Source File: TimelineClientImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static void main(String[] argv) throws Exception {
  CommandLine cliParser = new GnuParser().parse(opts, argv);
  if (cliParser.hasOption("put")) {
    String path = cliParser.getOptionValue("put");
    if (path != null && path.length() > 0) {
      if (cliParser.hasOption(ENTITY_DATA_TYPE)) {
        putTimelineDataInJSONFile(path, ENTITY_DATA_TYPE);
        return;
      } else if (cliParser.hasOption(DOMAIN_DATA_TYPE)) {
        putTimelineDataInJSONFile(path, DOMAIN_DATA_TYPE);
        return;
      }
    }
  }
  printUsage();
}
 
Example #5
Source File: TestTFileSeek.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #6
Source File: TestTFileSeqFileComparison.java    From RDFS with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #7
Source File: JackrabbitMain.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
public JackrabbitMain(final String[] args) throws ParseException {
    options.addOption("?", "help", false, "print this message");
    options.addOption("n", "notice", false, "print copyright notices");
    options.addOption("l", "license", false, "print license information");

    options.addOption("q", "quiet", false, "disable console output");
    options.addOption("d", "debug", false, "enable debug logging");

    options.addOption("h", "host", true, "IP address of the HTTP server");
    options.addOption("p", "port", true, "TCP port of the HTTP server (8080)");
    options.addOption("f", "file", true, "location of this jar file");
    options.addOption("r", "repo", true, "repository directory (jackrabbit)");
    options.addOption("c", "conf", true, "repository configuration file");

    command = new GnuParser().parse(options, args);
}
 
Example #8
Source File: TestTFileSeqFileComparison.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #9
Source File: AbstractCommand.java    From tmc-cli with MIT License 6 votes vote down vote up
protected CommandLine parseArgs(CliContext context, String[] stringArgs) {
    GnuParser parser = new GnuParser();
    CommandLine args;
    Options options = getOptions();

    Io io = context.getIo();

    try {
        args = parser.parse(options, stringArgs);
    } catch (ParseException e) {
        logger.warn("Invalid command line arguments.", e);
        io.errorln("Invalid command line arguments.");
        io.errorln(e.getMessage());
        return null;
    }

    if (args.hasOption("h")) {
        printHelp(context);
        return null;
    }
    return args;
}
 
Example #10
Source File: TimelineClientImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static void main(String[] argv) throws Exception {
  CommandLine cliParser = new GnuParser().parse(opts, argv);
  if (cliParser.hasOption("put")) {
    String path = cliParser.getOptionValue("put");
    if (path != null && path.length() > 0) {
      if (cliParser.hasOption(ENTITY_DATA_TYPE)) {
        putTimelineDataInJSONFile(path, ENTITY_DATA_TYPE);
        return;
      } else if (cliParser.hasOption(DOMAIN_DATA_TYPE)) {
        putTimelineDataInJSONFile(path, DOMAIN_DATA_TYPE);
        return;
      }
    }
  }
  printUsage();
}
 
Example #11
Source File: TaskAdmin.java    From helix with Apache License 2.0 6 votes vote down vote up
/** Attempts to parse options for given command, printing usage under failure */
private static CommandLine parseOptions(String[] args, Options options, String cmdStr) {
  CommandLineParser cliParser = new GnuParser();
  CommandLine cmd = null;

  try {
    cmd = cliParser.parse(options, args);
  } catch (ParseException pe) {
    LOG.error("CommandLineClient: failed to parse command-line options: " + pe.toString());
    printUsage(options, cmdStr);
    System.exit(1);
  }
  boolean ret = checkOptionArgsNumber(cmd.getOptions());
  if (!ret) {
    printUsage(options, cmdStr);
    System.exit(1);
  }

  return cmd;
}
 
Example #12
Source File: S3mper.java    From s3mper with Apache License 2.0 6 votes vote down vote up
private void processSQS(String [] args) throws Exception {
    GnuParser parser = new GnuParser();
    
    Options options = new Options();
    
    CommandLine cmdline = parser.parse(options, args);
    
    SQS_CMD cmd = SQS_CMD.valueOf(cmdline.getArgs()[0].toUpperCase());
    
    
    AlertJanitor janitor = new AlertJanitor();
    janitor.initalize(PathUtil.S3N, new Configuration());
    String queue = janitor.resolveQueueUrl(cmdline.getArgs()[1]);
    
    switch(cmd) {
        case LOG:
            janitor.writeLogs(queue, new Path(cmdline.getArgs()[2]));
            break;
        case PURGE:
            janitor.clearAll(queue);
            break;
        default: 
            usage();
    }
}
 
Example #13
Source File: TestTFileSeek.java    From RDFS with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #14
Source File: TestTFileSeqFileComparison.java    From big-c with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #15
Source File: TestTFileSeek.java    From big-c with Apache License 2.0 6 votes vote down vote up
public MyOptions(String[] args) {
  seed = System.nanoTime();

  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  }
  catch (ParseException e) {
    System.out.println(e.getMessage());
    System.out.println("Try \"--help\" option for details.");
    setStopProceed();
  }
}
 
Example #16
Source File: RegistryCli.java    From big-c with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public int rm(String[] args) {
  Option recursive = OptionBuilder.withArgName("recursive")
                                  .withDescription("delete recursively")
                                  .create("r");

  Options rmOption = new Options();
  rmOption.addOption(recursive);

  boolean recursiveOpt = false;

  CommandLineParser parser = new GnuParser();
  try {
    CommandLine line = parser.parse(rmOption, args);

    List<String> argsList = line.getArgList();
    if (argsList.size() != 2) {
      return usageError("RM requires exactly one path argument", RM_USAGE);
    }
    if (!validatePath(argsList.get(1))) {
      return -1;
    }

    try {
      if (line.hasOption("r")) {
        recursiveOpt = true;
      }

      registry.delete(argsList.get(1), recursiveOpt);
      return 0;
    } catch (Exception e) {
      syserr.println(analyzeException("rm", e, argsList));
    }
    return -1;
  } catch (ParseException exp) {
    return usageError("Invalid syntax " + exp.toString(), RM_USAGE);
  }
}
 
Example #17
Source File: RPCCallBenchmark.java    From big-c with Apache License 2.0 5 votes vote down vote up
private MyOptions(String args[]) {
  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  } catch (ParseException e) {
    System.err.println(e.getMessage());
    System.err.println("Try \"--help\" option for details.");
    failed = true;
  }
}
 
Example #18
Source File: QueryCli.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Options options = new Options();
        options.addOption(OPTION_METADATA);
        options.addOption(OPTION_SQL);

        CommandLineParser parser = new GnuParser();
        CommandLine commandLine = parser.parse(options, args);
        KylinConfig config = KylinConfig.createInstanceFromUri(commandLine.getOptionValue(OPTION_METADATA.getOpt()));
        String sql = commandLine.getOptionValue(OPTION_SQL.getOpt());

        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = QueryConnection.getConnection(null);

            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            int n = 0;
            ResultSetMetaData meta = rs.getMetaData();
            while (rs.next()) {
                n++;
                for (int i = 1; i <= meta.getColumnCount(); i++) {
                    System.out.println(n + " - " + meta.getColumnLabel(i) + ":\t" + rs.getObject(i));
                }
            }
        } finally {
            DBUtils.closeQuietly(rs);
            DBUtils.closeQuietly(stmt);
            DBUtils.closeQuietly(conn);
        }

    }
 
Example #19
Source File: QueueCLI.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public int run(String[] args) throws Exception {
  Options opts = new Options();

  opts.addOption(STATUS_CMD, true,
      "List queue information about given queue.");
  opts.addOption(HELP_CMD, false, "Displays help for all commands.");
  opts.getOption(STATUS_CMD).setArgName("Queue Name");

  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    sysout.println("Missing argument for options");
    printUsage(opts);
    return -1;
  }

  if (cliParser.hasOption(STATUS_CMD)) {
    if (args.length != 2) {
      printUsage(opts);
      return -1;
    }
    return listQueue(cliParser.getOptionValue(STATUS_CMD));
  } else if (cliParser.hasOption(HELP_CMD)) {
    printUsage(opts);
    return 0;
  } else {
    syserr.println("Invalid Command Usage : ");
    printUsage(opts);
    return -1;
  }
}
 
Example #20
Source File: gray_upgrade.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (args == null || args.length < 1) {
        System.out.println("Invalid parameter");
        usage();
        return;
    }
    String topologyName = args[0];
    String[] str2 = Arrays.copyOfRange(args, 1, args.length);
    CommandLineParser parser = new GnuParser();
    Options r = buildGeneralOptions(new Options());
    CommandLine commandLine = parser.parse(r, str2, true);

    int workerNum = 0;
    String component = null;
    List<String> workers = null;
    if (commandLine.hasOption("n")) {
        workerNum = Integer.valueOf(commandLine.getOptionValue("n"));
    }
    if (commandLine.hasOption("p")) {
        component = commandLine.getOptionValue("p");
    }
    if (commandLine.hasOption("w")) {
        String w = commandLine.getOptionValue("w");
        if (!StringUtils.isBlank(w)) {
            workers = Lists.newArrayList();
            String[] parts = w.split(",");
            for (String part : parts) {
                if (part.split(":").length == 2) {
                    workers.add(part.trim());
                }
            }
        }
    }
    upgradeTopology(topologyName, component, workers, workerNum);
}
 
Example #21
Source File: DistributedTestCLI.java    From incubator-retired-pirk with Apache License 2.0 5 votes vote down vote up
/**
 * Create and parse allowable options
 * 
 * @param args
 *          - arguments fed into the main method
 */
public DistributedTestCLI(String[] args)
{
  // create the command line options
  cliOptions = createOptions();

  try
  {
    // parse the command line options
    CommandLineParser parser = new GnuParser();
    commandLine = parser.parse(cliOptions, args, true);

    // if help option is selected, just print help text and exit
    if (hasOption("h"))
    {
      printHelp();
      System.exit(1);
    }

    // The full path of the jar file must be set
    if (!hasOption("j"))
    {
      logger.info("The full path of the jar file must be set with -j");
      System.exit(1);
    }
  } catch (Exception e)
  {
    e.printStackTrace();
    System.exit(1);
  }
}
 
Example #22
Source File: RPCCallBenchmark.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private MyOptions(String args[]) {
  try {
    Options opts = buildOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(opts, args, true);
    processOptions(line, opts);
    validateOptions();
  } catch (ParseException e) {
    System.err.println(e.getMessage());
    System.err.println("Try \"--help\" option for details.");
    failed = true;
  }
}
 
Example #23
Source File: LogFilePrinterMain.java    From secor with Apache License 2.0 5 votes vote down vote up
private static CommandLine parseArgs(String[] args) throws ParseException {
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("file")
            .withDescription("sequence file to read")
            .hasArg()
            .withArgName("<sequence_file_name>")
            .withType(String.class)
            .create("f"));
    options.addOption("o", "print_offsets_only", false, "whether to print only offsets " +
            "ignoring the message payload");

    CommandLineParser parser = new GnuParser();
    return parser.parse(options, args);
}
 
Example #24
Source File: Loops.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Runs the Loops tool.
 */
public int run(String[] args)
  throws Exception {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);
  
  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the web graph database to use");
  Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphDbOpts);

  CommandLineParser parser = new GnuParser();
  try {

    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("Loops", options);
      return -1;
    }

    String webGraphDb = line.getOptionValue("webgraphdb");
    findLoops(new Path(webGraphDb));
    return 0;
  }
  catch (Exception e) {
    LOG.error("Loops: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 
Example #25
Source File: PigStorage.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a Pig loader that uses specified character as a field delimiter.
 * <p>
 * Understands the following options, which can be specified in the second paramter:
 * <ul>
 * <li><code>-schema</code> Loads / Stores the schema of the relation using a hidden JSON file.
 * <li><code>-noschema</code> Ignores a stored schema during loading.
 * <li><code>-tagFile</code> Appends input source file name to beginning of each tuple.
 * <li><code>-tagPath</code> Appends input source file path to beginning of each tuple.
 * </ul>
 * @param delimiter the single byte character that is used to separate fields.
 * @param options a list of options that can be used to modify PigStorage behavior
 * @throws ParseException
 */
public PigStorage(String delimiter, String options) {
    fieldDel = StorageUtil.parseFieldDel(delimiter);
    Options validOptions = populateValidOptions();
    String[] optsArr = options.split(" ");
    try {
        CommandLineParser parser = new GnuParser();
        CommandLine configuredOptions = parser.parse(validOptions, optsArr);
        isSchemaOn = configuredOptions.hasOption("schema");
        if (configuredOptions.hasOption("overwrite")) {
            String value = configuredOptions.getOptionValue("overwrite");
            if ("true".equalsIgnoreCase(value)) {
                overwriteOutput = true;
            }
        }       
        dontLoadSchema = configuredOptions.hasOption("noschema");
        tagFile = configuredOptions.hasOption(TAG_SOURCE_FILE);
        tagPath = configuredOptions.hasOption(TAG_SOURCE_PATH);
        // TODO: Remove -tagsource in 0.13. For backward compatibility, we
        // need tagsource to be supported until at least 0.12
        if (configuredOptions.hasOption("tagsource")) {
            mLog.warn("'-tagsource' is deprecated. Use '-tagFile' instead.");
            tagFile = true;
        }
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp( "PigStorage(',', '[options]')", validOptions);
        // We wrap this exception in a Runtime exception so that
        // existing loaders that extend PigStorage don't break
        throw new RuntimeException(e);
    }
}
 
Example #26
Source File: RestAdminApplication.java    From helix with Apache License 2.0 5 votes vote down vote up
public static void processCommandLineArgs(String[] cliArgs) throws Exception {
  CommandLineParser cliParser = new GnuParser();
  Options cliOptions = constructCommandLineOptions();
  CommandLine cmd = null;

  try {
    cmd = cliParser.parse(cliOptions, cliArgs);
  } catch (ParseException pe) {
    System.err.println("RestAdminApplication: failed to parse command-line options: "
        + pe.toString());
    printUsage(cliOptions);
    System.exit(1);
  }
  int port = DEFAULT_PORT;
  if (cmd.hasOption(HELP)) {
    printUsage(cliOptions);
    return;
  } else if (cmd.hasOption(PORT)) {
    port = Integer.parseInt(cmd.getOptionValue(PORT));
  }

  HelixAdminWebApp app = new HelixAdminWebApp(cmd.getOptionValue(ZKSERVERADDRESS), port);
  app.start();
  try {
    Thread.currentThread().join();
  } finally {
    app.stop();
  }
}
 
Example #27
Source File: HAAdmin.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) {
  try {
    // Strip off the first arg, since that's just the command name
    argv = Arrays.copyOfRange(argv, 1, argv.length); 
    return new GnuParser().parse(opts, argv);
  } catch (ParseException pe) {
    errOut.println(cmdName.substring(1) +
        ": incorrect arguments");
    printUsage(errOut, cmdName);
    return null;
  }
}
 
Example #28
Source File: Application.java    From tmc-cli with MIT License 5 votes vote down vote up
public Application(CliContext context) {
    this.timeTracker = new TimeTracker(context);
    this.parser = new GnuParser();
    this.options = new Options();

    this.context = context;
    this.io = context.getIo();

    options.addOption(
            OptionBuilder.withLongOpt("help-all")
                    .withDescription("Display all help information of tmc-cli")
                    .create());
    options.addOption("h", "help", false, "Display help information");
    options.addOption("v", "version", false, "Give the version of the tmc-cli");
    options.addOption("u", "force-update", false, "Force the auto-update");
    options.addOption("d", "no-update", false, "Disable temporarily the auto-update");

    Set<String> helpCategories = CommandFactory.getCommandCategories();
    for (String category : helpCategories) {
        if (category.equals("") || category.equals("hidden")) {
            continue;
        }
        options.addOption(
                OptionBuilder.withLongOpt("help-" + category)
                        .withDescription("Display " + category + " help information")
                        .create());
    }

    //TODO implement the inTests as context.property
    if (!context.inTests()) {
        shutdownHandler = new ShutdownHandler(context.getIo());
        shutdownHandler.enable();
    }
}
 
Example #29
Source File: LinkRank.java    From anthelion with Apache License 2.0 5 votes vote down vote up
/**
 * Runs the LinkRank tool.
 */
public int run(String[] args)
  throws Exception {

  Options options = new Options();
  Option helpOpts = OptionBuilder.withArgName("help").withDescription(
    "show this help message").create("help");
  Option webgraphOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
    "the web graph db to use").create("webgraphdb");
  options.addOption(helpOpts);
  options.addOption(webgraphOpts);

  CommandLineParser parser = new GnuParser();
  try {

    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("LinkRank", options);
      return -1;
    }

    String webGraphDb = line.getOptionValue("webgraphdb");

    analyze(new Path(webGraphDb));
    return 0;
  }
  catch (Exception e) {
    LOG.error("LinkAnalysis: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 
Example #30
Source File: GenericOptionsParser.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Parse the user-specified options, get the generic options, and modify
 * configuration accordingly
 * @param opts Options to use for parsing args.
 * @param conf Configuration to be modified
 * @param args User-specified arguments
 */
private void parseGeneralOptions(Options opts, Configuration conf, 
    String[] args) throws IOException {
  opts = buildGeneralOptions(opts);
  CommandLineParser parser = new GnuParser();
  try {
    commandLine = parser.parse(opts, preProcessForWindows(args), true);
    processGeneralOptions(conf, commandLine);
  } catch(ParseException e) {
    LOG.warn("options parsing failed: "+e.getMessage());

    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("general options are: ", opts);
  }
}