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:is.merkor.cli.MerkorCommandLineOptions.java

private static void createArgumentOptions() {
    input = OptionBuilder.withArgName("input file or directory").hasArg()
            .withDescription("the input file or directory").create("input");
    output = OptionBuilder.withArgName("output file or directory").hasArg()
            .withDescription("the output file or directory").create("output");
    db_conn = OptionBuilder.withArgName("db connection to use").hasArg()
            .withDescription("db connection to use (maybe class DBConnection has to be adjusted!)")
            .create("db_conn");
    db_name = OptionBuilder.withArgName("name of the database").hasArg().withDescription("name of the database")
            .create("db_name");
    password = OptionBuilder.withArgName("password").hasArg().withDescription("password - no encryption!")
            .create("password");
    relation = OptionBuilder.withArgName("relation").hasArg().withDescription("relation to look for")
            .create("relation");

}

From source file:cz.muni.fi.pa165.creatures.rest.client.utils.OptionsProvider.java

public Options getOptions() {
    if (options != null) {
        return OptionsProvider.options;
    }//from  w w  w  .  j  a  va  2  s.co  m

    OptionsProvider.options = new Options();

    Option help = new Option("h", "prints this help");

    Option uri = OptionBuilder.withArgName("uri").hasArg().withDescription("uri of the resource we query")
            .create("u");

    Option operation = OptionBuilder.withArgName("operation").hasArg()
            .withDescription("operation, C, R, U, D, A or N").create("o");

    Option idOfEntity = OptionBuilder.withArgName("id").hasArg().withDescription("id of an entity to deal with")
            .create("i");

    Option name = OptionBuilder.withArgName("name").hasArg()
            .withDescription("name of an entity of a choosen mode").create("n");

    // WEAPON
    Option weapon = OptionBuilder.withDescription("weapon mode").create("w");

    Option ammunition = OptionBuilder.withArgName("ammunition").hasArg()
            .withDescription("ammunition of a weapon in bullets").create("m");

    Option range = OptionBuilder.withArgName("range").hasArg().withDescription("range of a weapon in meters")
            .create("g");

    // REGION
    Option region = OptionBuilder.withDescription("region mode").create("r");

    Option description = OptionBuilder.withArgName("description").hasArg()
            .withDescription("description of a region").create("d");

    Option area = OptionBuilder.withArgName("area").hasArg()
            .withDescription("area of region in square kilometers").create("a");

    options.addOption(help);
    options.addOption(uri);
    options.addOption(weapon);
    options.addOption(region);
    options.addOption(operation);
    options.addOption(idOfEntity);
    options.addOption(name);
    options.addOption(ammunition);
    options.addOption(range);
    options.addOption(description);
    options.addOption(area);

    return OptionsProvider.options;

}

From source file:il.ac.tau.yoavram.pes.PesCommandLineParser.java

@SuppressWarnings("static-access")
private static Options createOptions() {
    Options options = new Options();
    Option xml = OptionBuilder.withArgName("file").hasArg().isRequired(true).withLongOpt("xml")
            .withDescription("Spring XML configuration file").create(OptCode.Xml.toString());
    Option log = OptionBuilder.withArgName("file").hasArg().withLongOpt("log")
            .withDescription("log4j config filename").create(OptCode.Log.toString());
    Option pfile = OptionBuilder.withArgName("file").hasArg().withLongOpt("pfile")
            .withDescription("properties filename").create(OptCode.FileProperties.toString());
    Option properties = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("properties (override properties file)").withLongOpt("properties")
            .create(OptCode.Properties.toString());
    Option help = new Option(OptCode.Help.toString(), "help", false, "print this message");

    options.addOption(xml).addOption(pfile).addOption(log).addOption(properties).addOption(help);
    return options;
}

From source file:com.example.geomesa.accumulo.AccumuloQuickStart.java

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

    Option instanceIdOpt = OptionBuilder.withArgName(INSTANCE_ID).hasArg().isRequired()
            .withDescription("the ID (name) of the Accumulo instance, e.g:  mycloud").create(INSTANCE_ID);
    options.addOption(instanceIdOpt);

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

    Option userOpt = OptionBuilder.withArgName(USER).hasArg().isRequired()
            .withDescription("the Accumulo user that will own the connection, e.g.:  root").create(USER);
    options.addOption(userOpt);

    Option passwordOpt = OptionBuilder.withArgName(PASSWORD).hasArg().isRequired()
            .withDescription("the password for the Accumulo user that will own the connection, e.g.:  toor")
            .create(PASSWORD);
    options.addOption(passwordOpt);

    Option authsOpt = OptionBuilder.withArgName(AUTHS).hasArg().withDescription(
            "the (optional) list of comma-separated Accumulo authorizations that should be applied to all data written or read by this Accumulo user; note that this is NOT the list of low-level database permissions such as 'Table.READ', but more a series of text tokens that decorate cell data, e.g.:  Accounting,Purchasing,Testing")
            .create(AUTHS);
    options.addOption(authsOpt);

    Option tableNameOpt = OptionBuilder.withArgName(TABLE_NAME).hasArg().isRequired().withDescription(
            "the name of the Accumulo table to use -- or create, if it does not already exist -- to contain the new data")
            .create(TABLE_NAME);
    options.addOption(tableNameOpt);

    return options;
}

From source file:cc.wikitools.lucene.hadoop.ScoreWikipediaArticleHdfs.java

@SuppressWarnings("static-access")
@Override//w ww .  j a  v a  2s .com
public int run(String[] args) throws Exception {
    Options options = new Options();
    options.addOption(
            OptionBuilder.withArgName("path").hasArg().withDescription("index location").create(INDEX_OPTION));
    options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("id").create(ID_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("title").create(TITLE_OPTION));
    options.addOption(
            OptionBuilder.withArgName("string").hasArg().withDescription("query text").create(QUERY_OPTION));

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!(cmdline.hasOption(ID_OPTION) || cmdline.hasOption(TITLE_OPTION)) || !cmdline.hasOption(INDEX_OPTION)
            || !cmdline.hasOption(QUERY_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(ScoreWikipediaArticleHdfs.class.getName(), options);
        System.exit(-1);
    }

    String indexLocation = cmdline.getOptionValue(INDEX_OPTION);
    String queryText = cmdline.getOptionValue(QUERY_OPTION);

    HdfsWikipediaSearcher searcher = new HdfsWikipediaSearcher(new Path(indexLocation), getConf());
    PrintStream out = new PrintStream(System.out, true, "UTF-8");

    if (cmdline.hasOption(ID_OPTION)) {
        out.println("score: "
                + searcher.scoreArticle(queryText, Integer.parseInt(cmdline.getOptionValue(ID_OPTION))));
    } else {
        out.println("score: " + searcher.scoreArticle(queryText, cmdline.getOptionValue(TITLE_OPTION)));
    }

    searcher.close();
    out.close();

    return 0;
}

From source file:fr.ens.biologie.genomique.eoulsan.MainCLI.java

/**
 * Create options for command line// w  ww .  ja v  a  2 s.co m
 * @return an Options object
 */
@Override
@SuppressWarnings("static-access")
protected Options makeOptions() {

    // create Options object
    final Options options = super.makeOptions();

    // eoulsan.sh shell script options
    options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("JAVA_HOME path").create('j'));

    options.addOption(OptionBuilder.withArgName("size").hasArg()
            .withDescription("maximal memory usage for JVM in MB (2048 by default)").create('m'));

    options.addOption(OptionBuilder.withArgName("args").hasArg()
            .withDescription("JVM arguments (-server by default)").create('J'));

    options.addOption(
            OptionBuilder.withArgName("path").hasArg().withDescription("JVM working directory").create('w'));

    options.addOption(OptionBuilder.withArgName("classpath").hasArg()
            .withDescription("additional classpath for eoulsan plugins").create('p'));

    return options;
}

From source file:edu.indiana.d2i.sloan.internal.DeleteVMSimulator.java

@Override
protected void initOptions() {
    options = new Options();

    Option wdir = OptionBuilder.withArgName("workingdir").isRequired().hasArg()
            .withDescription("working directory").create(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR));

    options.addOption(wdir);//  www .j a v  a2  s  .co m
}

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

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

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

    Option zookeepers = OptionBuilder.withArgName(ZOOKEEPERS_PARAM).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_PARAM);
    options.addOption(zookeepers);

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

    Option partitions = OptionBuilder.withArgName(PARTITIONS).hasArg()
            .withDescription("Number of partitions to use in Kafka topics").create(PARTITIONS);
    options.addOption(partitions);

    Option replication = OptionBuilder.withArgName(REPLICATION).hasArg()
            .withDescription("Replication factor to use in Kafka topics").create(REPLICATION);
    options.addOption(replication);

    Option load = OptionBuilder.withArgName(LOAD).hasArg().withDescription("Number of entities to simulate.")
            .create(LOAD);
    options.addOption(load);

    Option visibility = OptionBuilder.withArgName(VISIBILITY).hasArg()
            .withDescription("Visibilities to set on each feature created").create(VISIBILITY);
    options.addOption(visibility);

    Option delay = OptionBuilder.withArgName(DELAY).hasArg()
            .withDescription("Delay (in ms) between each write of features").create(DELAY);
    options.addOption(delay);

    return options;
}

From source file:com.muni.fi.pa165.survive.rest.client.utils.OptionsProvider.java

public Options getOptions() {
    if (options != null) {
        return OptionsProvider.options;
    }/*w ww .  j av  a 2 s  .  com*/

    options = new Options();

    Option help = new Option("h", "Print help");

    Option operation = OptionBuilder.withArgName("operation").hasArg()
            .withDescription("operation, C, R, U, D, A").create("o");

    Option id = OptionBuilder.withArgName("id").hasArg().withDescription("Entity ID").create("i");

    Option name = OptionBuilder.withArgName("name").hasArg()
            .withDescription("name of an entity of a choosen mode").create("n");

    // WEAPON
    Option weapon = OptionBuilder.withDescription("Weapon Management").create("w");

    Option caliber = OptionBuilder.withArgName("caliber").hasArg().withDescription("Weapon ammo caliber (mm)")
            .create("m");
    Option range = OptionBuilder.withArgName("range").hasArg().withDescription("Weapon range in meters")
            .create("g");
    Option rounds = OptionBuilder.withArgName("rounds").hasArg()
            .withDescription("Number of rounds a weapon holds").create("r");
    Option weaponType = OptionBuilder.withArgName("Weapon Type").hasArg()
            .withDescription("Weapon Type: " + WeaponType.getList()).create("t");

    Option weaponClass = OptionBuilder.withArgName("Weapon Class").hasArg()
            .withDescription("Weapon Class: " + WeaponClass.getList()).create("c");

    //AREA
    Option area = OptionBuilder.withDescription("Area Management").create("a");

    Option description = OptionBuilder.withArgName("Description").hasArg().withDescription("Area description")
            .create("d");

    Option terrain = OptionBuilder.withArgName("Area Terrain").hasArg()
            .withDescription("Terrain Type: " + TerrainType.getList()).create("q");

    options.addOption(help);
    options.addOption(weaponType);
    options.addOption(weaponClass);
    options.addOption(rounds);
    options.addOption(weapon);
    options.addOption(area);
    options.addOption(operation);
    options.addOption(id);
    options.addOption(name);
    options.addOption(caliber);
    options.addOption(range);
    options.addOption(description);
    options.addOption(terrain);

    return options;

}

From source file:fr.jayasoft.ivy.Main.java

private static Options getOptions() {
    Option conf = OptionBuilder.withArgName("conffile").hasArg()
            .withDescription("use given file for configuration").create("conf");
    Option cache = OptionBuilder.withArgName("cachedir").hasArg()
            .withDescription("use given directory for cache").create("cache");
    Option ivyfile = OptionBuilder.withArgName("ivyfile").hasArg().withDescription("use given file as ivy file")
            .create("ivy");
    Option dependency = OptionBuilder.withArgName("organisation module revision").hasArgs()
            .withDescription(//from w  w  w. j  a v a2s . co  m
                    "use this instead of ivy file to do the rest of the work with this as a dependency.")
            .create("dependency");
    Option confs = OptionBuilder.withArgName("configurations").hasArgs()
            .withDescription("resolve given configurations").create("confs");
    Option retrieve = OptionBuilder.withArgName("retrievepattern").hasArg()
            .withDescription("use given pattern as retrieve pattern").create("retrieve");
    Option cachepath = OptionBuilder.withArgName("cachepathfile").hasArg().withDescription(
            "outputs a classpath consisting of all dependencies in cache (including transitive ones) of the given ivy file to the given cachepathfile")
            .create("cachepath");
    Option revision = OptionBuilder.withArgName("revision").hasArg()
            .withDescription("use given revision to publish the module").create("revision");
    Option status = OptionBuilder.withArgName("status").hasArg()
            .withDescription("use given status to publish the module").create("status");
    Option deliver = OptionBuilder.withArgName("ivypattern").hasArg()
            .withDescription("use given pattern as resolved ivy file pattern").create("deliverto");
    Option publishResolver = OptionBuilder.withArgName("resolvername").hasArg()
            .withDescription("use given resolver to publish to").create("publish");
    Option publishPattern = OptionBuilder.withArgName("artpattern").hasArg()
            .withDescription("use given pattern to find artifacts to publish").create("publishpattern");
    Option realm = OptionBuilder.withArgName("realm").hasArg().withDescription("use given realm for HTTP AUTH")
            .create("realm");
    Option host = OptionBuilder.withArgName("host").hasArg().withDescription("use given host for HTTP AUTH")
            .create("host");
    Option username = OptionBuilder.withArgName("username").hasArg()
            .withDescription("use given username for HTTP AUTH").create("username");
    Option passwd = OptionBuilder.withArgName("passwd").hasArg()
            .withDescription("use given password for HTTP AUTH").create("passwd");
    Option main = OptionBuilder.withArgName("main").hasArg()
            .withDescription("the main class to runtime process").create("main");
    Option args = OptionBuilder.withArgName("args").hasArgs()
            .withDescription("the arguments to runtime process").create("args");

    Options options = new Options();

    options.addOption("debug", false, "set message level to debug");
    options.addOption("verbose", false, "set message level to verbose");
    options.addOption("warn", false, "set message level to warn");
    options.addOption("error", false, "set message level to error");
    options.addOption("novalidate", false, "do not validate ivy files against xsd");
    options.addOption("useOrigin", false,
            "use original artifact location with local resolvers instead of copying to the cache");
    options.addOption("sync", false, "in conjonction with -retrieve, does a synced retrieve");
    options.addOption("m2compatible", false, "use maven2 compatibility");
    options.addOption("?", false, "display this help");
    options.addOption(conf);
    options.addOption(confs);
    options.addOption(cache);
    options.addOption(ivyfile);
    options.addOption(dependency);
    options.addOption(retrieve);
    options.addOption(cachepath);
    options.addOption(revision);
    options.addOption(status);
    options.addOption(deliver);
    options.addOption(publishResolver);
    options.addOption(publishPattern);
    options.addOption(realm);
    options.addOption(host);
    options.addOption(username);
    options.addOption(passwd);
    options.addOption(main);
    options.addOption(args);

    return options;
}