Example usage for org.apache.commons.cli OptionBuilder withArgName

List of usage examples for org.apache.commons.cli OptionBuilder withArgName

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder withArgName.

Prototype

public static OptionBuilder withArgName(String name) 

Source Link

Document

The next Option created will have the specified argument value name.

Usage

From source file:com.rainerschuster.webidl.scraper.ScraperOptions.java

public void defineOptions() {
    options = new Options();

    final Option fileOption = OptionBuilder.withArgName("file").hasArg().withDescription("output file")
            .create("o");
    options.addOption(fileOption);/*from   w  w w .  ja  v a2 s  .  c om*/

    final Option modeOption = OptionBuilder.withArgName("mode").hasArg().withDescription("parse mode")
            .create("m");

    final Option recursiveOption = OptionBuilder.withArgName("recursive").withDescription("recursive")
            .create("r");

    options.addOption(fileOption);
    options.addOption(modeOption);
    options.addOption(recursiveOption);
}

From source file:ape.ContinueNodeCommand.java

/**
 * The constructor for this command simply creates its Option object (used by
 * the CLI parser)/*from w  w  w.j  av  a 2  s  .  c o m*/
 */
public ContinueNodeCommand() {
    option = OptionBuilder.withArgName("NodeType").hasArgs(1).withValueSeparator().withDescription(
            "Continues a tasktracker or a datanode at the given hostname that has already been suspended")
            .withLongOpt("continue-node").create("e");
}

From source file:edu.odu.cs.cs350.yellow1.ui.cli.ClI.java

@SuppressWarnings("static-access")
private static Options getOptions() {
    Options opts = new Options();
    opts.addOption("help", false, "Display help information");
    Option src = OptionBuilder.withArgName("src folder").hasArg()
            .withDescription("The parent folder for the coding project").create("src");
    Option zipd = OptionBuilder.hasArg().withArgName("zipped src folder").hasArg()
            .withDescription("the src folder is zipped y:n").create('z');
    Option mutFile = OptionBuilder.hasArg().withArgName("file to be mutated").hasArg()
            .withDescription("The file name to be mutated. Requires full path").create("mutF");
    Option testSuitePath = OptionBuilder.hasArg().withArgName("project test suite").hasArg()
            .withDescription("The test suite for the project. Requires full path").create("testSte");
    Option goldOutput = OptionBuilder.hasArg().withArgName("gold version output").hasArg()
            .withDescription("The output for the gold program. Requires full path").create("goldOut");
    opts.addOption(src);/*from  w ww .j  ava2  s  . c o m*/
    opts.addOption(zipd);
    opts.addOption(mutFile);
    opts.addOption(testSuitePath);
    opts.addOption(goldOutput);
    return opts;
}

From source file:com.example.geomesa.kafka.KafkaQuickStart.java

public static Options getCommonRequiredOptions() {
    Options options = new Options();

    Option kafkaBrokers = OptionBuilder.withArgName("brokers").hasArg().isRequired()
            .withDescription("The comma-separated list of Kafka brokers, e.g. localhost:9092")
            .create("brokers");
    options.addOption(kafkaBrokers);/*  w  ww  .j ava  2s . c  om*/

    Option zookeepers = OptionBuilder.withArgName("zookeepers").hasArg().isRequired().withDescription(
            "The comma-separated list of Zookeeper nodes that support your Kafka instance, e.g.: zoo1:2181,zoo2:2181,zoo3:2181")
            .create("zookeepers");
    options.addOption(zookeepers);

    Option zkPath = OptionBuilder.withArgName("zkPath").hasArg()
            .withDescription("Zookeeper's discoverable path for metadata, defaults to /geomesa/ds/kafka")
            .create("zkPath");
    options.addOption(zkPath);

    Option visibility = OptionBuilder.withArgName("visibility").hasArg().create("visibility");
    options.addOption(visibility);

    Option automated = OptionBuilder.withArgName("automated").create("automated");
    options.addOption(automated);

    return options;
}

From source file:ape.PacketFloodingCommand.java

/**
 * The constructor for this command simply creates its Option object (used by
 * the CLI parser)/*from  w w w.ja  va  2  s .  com*/
 */
public PacketFloodingCommand() {
    option = OptionBuilder.withArgName("hostname> <port> <duration").hasArgs(3).withValueSeparator()
            .withDescription(
                    "Flood the target hostname with a DoS attack.  For proper effect, use the -R flag and designate more than one host.")
            .withLongOpt("udp-flood").create("u");
}

From source file:commandline.CommandLineInterface.java

@SuppressWarnings("static-access")
public CommandLineInterface(String[] args) {
    // create the Options
    Options options = new Options();
    // create the command line parser
    CommandLineParser parser = new GnuParser();

    Option port = OptionBuilder.withArgName("port").hasArg().isRequired().withDescription("Port Number")
            .create("s");

    Option localWorker = OptionBuilder.withArgName("N_workers").hasArg()
            .withDescription("Run local worker threads").create("lw");

    Option remoteWorker = OptionBuilder.withDescription("Run remote worker").create("rw");

    options.addOption(port);/* w  w  w.j  a  va  2s . c  o  m*/
    options.addOption(localWorker);
    options.addOption(remoteWorker);

    try {
        // parse the command line arguments
        command = parser.parse(options, args);
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
    }

}

From source file:com.rockagen.commons.util.CLITest.java

@Test
@Ignore/*  w  w w. j  a va2  s. c  om*/
public void testCLI() {

    // create the Options
    Options options = new Options();
    options.addOption("h", "help", false, "print help for the command.");
    options.addOption("v", "verbose", false, "verbose");
    OptionBuilder.withArgName("property=value");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withLongOpt("desc");
    OptionBuilder.withValueSeparator();
    OptionBuilder.withDescription("use value for given property");
    options.addOption(OptionBuilder.create("D"));

    OptionBuilder.withArgName("file1,file2...");
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("input");
    OptionBuilder.withValueSeparator(' ');
    OptionBuilder.withDescription("file name");
    options.addOption(OptionBuilder.create("i"));

    String formatstr = "CLITest [-h/--help][-v/--verbose]..";
    try {
        String[] args = { "CLITest", "--help", "-v", "-s", "--desc", "name=value", "--input", "file1", "file2",
                "file3" };
        // parse the command line arguments
        CommandLine line = CmdUtil.parse(options, args);

        if (line.hasOption("h")) {
            CmdUtil.printHelp(formatstr, "weclome usa", options,
                    "If you hava some quesion,please mail to agen@rockagen.com");
        }
        if (line.hasOption("v")) {
            System.out.println("VERSION 0.0.1");
        }
        if (line.hasOption("D")) {
            System.out.println("hey,guys,you input " + ArrayUtil.toString(line.getOptionValues("D")));
        }
        if (line.hasOption("i")) {
            System.out.println("hey,guys,you input " + ArrayUtil.toString(line.getOptionValues("i")));
        } else {
            CmdUtil.printHelp(formatstr, options);
        }
    } catch (ParseException exp) {
        CmdUtil.printHelp(formatstr, options);
        System.err.println();
        System.err.println(exp.getMessage());
    }

}

From source file:com.example.geomesa.hbase.HBaseQuickStart.java

/**
 * Creates a common set of command-line options for the parser.  Each option
 * is described separately./*from   w  ww .j  a  va2  s.c om*/
 */
static Options getCommonRequiredOptions() {
    Options options = new Options();

    Option tableNameOpt = OptionBuilder.withArgName(TABLE_NAME).hasArg().isRequired()
            .withDescription("table name").create(TABLE_NAME);
    options.addOption(tableNameOpt);

    return options;
}

From source file:HDFSFileFinder.java

private static Options createCommandLineOptions() {
    Options options = new Options();
    Option host = OptionBuilder.withArgName("fs.default.name").hasArg()
            .withDescription("fs.default.name of hadoop namenode e.g. hdfs://localhost:9000").create("h");
    options.addOption(host);//  w ww.j a  va 2 s  .co m
    Option filename = OptionBuilder.withArgName("filename").hasArg()
            .withDescription("The file to show node locations for").create("f");
    options.addOption(filename);
    Option debug = OptionBuilder.withArgName("verbose").withDescription("Provide debug output").create("v");
    options.addOption(debug);
    return options;
}

From source file:ape.SuspendNodeCommand.java

/**
 * The constructor for this command simply creates its Option object (used by
 * the CLI parser)//from  ww w  .  j  a  v  a  2 s.  co  m
 */
public SuspendNodeCommand() {
    option = OptionBuilder.withArgName("NodeType").hasArgs(1).withValueSeparator()
            .withDescription("Suspends a tasktracker or a datanode at the given hostname")
            .withLongOpt("suspend-node").create("s");
}