Package org.apache.commons.cli

Examples of org.apache.commons.cli.GnuParser


        .addOption("F", "filename", true, "file to stream to avro source")
        .addOption("R", "headerFile", true, ("file containing headers as " +
            "key/value pairs on each new line"))
        .addOption("h", "help", false, "display help text");

    CommandLineParser parser = new GnuParser();
    CommandLine commandLine = parser.parse(options, args);

    if (commandLine.hasOption('h')) {
      new HelpFormatter().printHelp("flume-ng avro-client", options, true);

      return false;
View Full Code Here


  }

  private boolean parseOption(String[] args) throws ParseException {
    if (args.length == 0) return false; // no args shows help.

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = parser.parse(options, args);
    if (cmd.hasOption("h")) {
      printUsage();
      return false;
    }
    if (cmd.hasOption("execute")) upgrade = true;
View Full Code Here

    Option combinedStd = new Option("xc",false,"output using a standard metadata schema and include FITS xml");
    outputOptions.addOption(stdxml);
    outputOptions.addOption(combinedStd);
    options.addOptionGroup(outputOptions);

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = parser.parse(options, args);
   
    if(cmd.hasOption("h")) {
      fits.printHelp(options);
      System.exit(0);
    }
View Full Code Here

    if (args.length < 1) {
      printHelpMessage(printOpts);
      return -1;
    }

    CommandLineParser parser = new GnuParser();
    String appIdStr = null;
    String containerIdStr = null;
    String nodeAddress = null;
    String appOwner = null;
    try {
      CommandLine commandLine = parser.parse(opts, args, true);
      appIdStr = commandLine.getOptionValue(APPLICATION_ID_OPTION);
      containerIdStr = commandLine.getOptionValue(CONTAINER_ID_OPTION);
      nodeAddress = commandLine.getOptionValue(NODE_ADDRESS_OPTION);
      appOwner = commandLine.getOptionValue(APP_OWNER_OPTION);
    } catch (ParseException e) {
View Full Code Here

        if (args.length == 0) {
            throw new ParseException("missing sub-command");
        }
        else {
            if (commands.containsKey(args[0])) {
                GnuParser parser = new GnuParser();
                String[] minusCommand = new String[args.length - 1];
                System.arraycopy(args, 1, minusCommand, 0, minusCommand.length);
                return new Command(args[0], parser.parse(commands.get(args[0]), minusCommand,
                                                         commandWithArgs.get(args[0])));
            }
            else {
                throw new ParseException(MessageFormat.format("invalid sub-command [{0}]", args[0]));
            }
View Full Code Here

        .create('D'));

    // [-h|--help]
    options.addOption(new Option("h", "help", false, "Print help information"));

    Parser parser = new GnuParser();
    CommandLine cmdLine = null;

    try {
      cmdLine = parser.parse(options, args);

    } catch (ParseException e) {
      printUsage(options, ss.err);
      System.exit(1);
    }
View Full Code Here

    logger.info("Starting Tika Server " + new Tika().toString());

    try {
      Options options = getOptions();

      CommandLineParser cliParser = new GnuParser();
      CommandLine line = cliParser.parse(options, args);

      if (line.hasOption("help")) {
          HelpFormatter helpFormatter = new HelpFormatter();
          helpFormatter.printHelp("tikaserver", options);
          System.exit(-1);
View Full Code Here

      Options options = new Options();
      options.addOption("s", "start", true, "start key");
      options.addOption("e", "end", true, "end key");
      options.addOption("l", "limit", true, "number to print");

      GnuParser parser = new GnuParser();
      CommandLine cmd = null;
      try {
        cmd = parser.parse(options, args);
        if (cmd.getArgs().length != 0) {
          throw new ParseException("Command takes no arguments");
        }
      } catch (ParseException e) {
        System.err.println("Failed to parse command line " + e.getMessage());
View Full Code Here

    options.addOption(helpOpts);
    options.addOption(webGraphOpts);
    options.addOption(segOpts);
    options.addOption(outputOpts);

    CommandLineParser parser = new GnuParser();
    try {

      CommandLine line = parser.parse(options, args);
      if (line.hasOption("help") || !line.hasOption("webgraphdb")
        || !line.hasOption("output") || !line.hasOption("segment")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("BasicFields", options);
        return -1;
View Full Code Here

  private static class Walker extends Configured implements Tool {
    public int run(String[] args) throws IOException {
      Options options = new Options();
      options.addOption("n", "num", true, "number of queries");

      GnuParser parser = new GnuParser();
      CommandLine cmd = null;
      try {
        cmd = parser.parse(options, args);
        if (cmd.getArgs().length != 0) {
          throw new ParseException("Command takes no arguments");
        }
      } catch (ParseException e) {
        System.err.println("Failed to parse command line " + e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.GnuParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.