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:junkProducer.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);/*w  ww .j a  v  a 2s  .  co m*/

    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);

    return options;
}

From source file:is.merkor.core.cli.MerkorCoreCommandLineOptions.java

private static void createArgumentOptions() {
    host = OptionBuilder.withArgName("Redis host").hasArg()
            .withDescription("the host for Redis (default=localhost)").create("host");
    port = OptionBuilder.withArgName("Redis port").hasArg().withDescription("the port for Redis (default=6379)")
            .create("port");
    items = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all lexical items having given lemma as lemma").create("items");
    relations = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all relations for the given lemma").create("relations");
    rel_from = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all relations having the given lemma as the left element").create("rel_from");
    rel_to = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all relations having the given lemma as the right element").create("rel_to");
    rel_type = OptionBuilder.withArgName("rel_type").hasArg()
            .withDescription("get all relations having the given relation type").create("rel_type");
    number = OptionBuilder.withArgName("number").hasArg()
            .withDescription("get the n top elements from required list of relations").create("n");
    cluster_id = OptionBuilder.withArgName("cluster_id").hasArg()
            .withDescription("get the cluster with the given id").create("cluster_id");
    clusters_matching = OptionBuilder.withArgName("regex").hasArg()
            .withDescription("get all clusters matching the given regex").create("clusters_matching");
    clusters_having = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all clusters having the given lemma").create("clusters_having");
    domains_having = OptionBuilder.withArgName("lemma").hasArg()
            .withDescription("get all domains the given lemma belongs to").create("domains_having");
    items_for_cluster = OptionBuilder.withArgName("cluster_id").hasArg()
            .withDescription("get all lexical items belonging to the given cluster")
            .create("items_for_cluster");
    items_for_domain = OptionBuilder.withArgName("domain").hasArg()
            .withDescription("get all lexical items belonging to the given domain").create("items_for_domain");
}

From source file:com.aliyun.openservices.odps.console.commands.logview.GetSummaryAction.java

@SuppressWarnings("static-access")
public Options getOptions() {
    Options options = super.getOptions();
    options.addOption(OptionBuilder.withArgName("task name").hasArg().create('t'));
    return options;
}

From source file:com.kaaprotech.satu.util.CmdLineUtil.java

@SuppressWarnings("static-access")
private static Options getOptions() {
    final Options options = new Options();
    OptionBuilder.create("init");
    final Option in = OptionBuilder.withArgName(IN).hasArgs().withDescription("One or more model files")
            .isRequired().create(IN);// w  w  w  .j  a  va 2s . c  om
    options.addOption(in);
    final Option out = OptionBuilder.withArgName(OUT).hasArg().withDescription("Output root directory")
            .isRequired().create(OUT);
    options.addOption(out);
    final Option json = OptionBuilder.withArgName(JSON).hasArg(false)
            .withDescription("Add json support to generated code").isRequired(false).create(JSON);
    options.addOption(json);
    return options;
}

From source file:ape.CorruptFileCommand.java

/**
 * The constructor for this command simply creates its Option object (used by
 * the CLI parser)//www .j  a va2s .  com
 */
public CorruptFileCommand() {
    option = OptionBuilder.withArgName("file> <size> <offset").hasArgs(3).withValueSeparator().withDescription(
            "Corrupt the file given the address as the first argument, size as the 2nd arg, and offset as the 3rd argument")
            .withLongOpt("corrupt-file").create("c");
}

From source file:edu.hku.sdb.driver.SdbDriver.java

/**
 *
 * @return//from   ww  w .  j  ava2  s .c om
 */
@SuppressWarnings("static-access")
private static Options buildOptions() {

    // Build the options
    Option startOption = OptionBuilder.withArgName(START).create(START);

    Option confOption = OptionBuilder.withArgName(CONF).hasArg().withDescription("The configuration directory")
            .create(CONF);

    Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("use value for given property").create("D");

    Option helpOption = OptionBuilder.withArgName(HELP).create(HELP);

    // Declare the options
    Options opts = new Options();
    opts.addOption(startOption);
    opts.addOption(helpOption);
    opts.addOption(confOption);
    opts.addOption(property);

    return opts;
}

From source file:luceneGazateer.EntryData.java

public static void main(String[] args) throws IOException {
    Option buildOpt = OptionBuilder.withArgName("gazetteer file").hasArg().withLongOpt("build")
            .withDescription("The Path to the Geonames allCountries.txt").create('b');

    Option searchOpt = OptionBuilder.withArgName("set of location names").withLongOpt("search").hasArgs()
            .withDescription("Location names to search the Gazetteer for").create('s');

    Option indexOpt = OptionBuilder.withArgName("directoryPath").withLongOpt("index").hasArgs()
            .withDescription("The path to the Lucene index directory to either create or read").create('i');

    Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h');

    String indexPath = null;/*w  w w . j ava  2  s  .co m*/
    String gazetteerPath = null;
    ArrayList<String> geoTerms = null;
    Options options = new Options();
    options.addOption(buildOpt);
    options.addOption(searchOpt);
    options.addOption(indexOpt);
    options.addOption(helpOpt);

    // create the parser
    CommandLineParser parser = new DefaultParser();
    GeoNameResolver resolver = new GeoNameResolver();

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("index")) {
            indexPath = line.getOptionValue("index");
        }

        if (line.hasOption("build")) {
            gazetteerPath = line.getOptionValue("build");
        }

        if (line.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("lucene-geo-gazetteer", options);
            System.exit(1);
        }

        if (indexPath != null && gazetteerPath != null) {
            LOG.info("Building Lucene index at path: [" + indexPath + "] with geoNames.org file: ["
                    + gazetteerPath + "]");
            resolver.buildIndex(gazetteerPath, indexPath);
        }

        if (line.hasOption("search")) {
            String temp_s = "";
            for (String string : line.getOptionValues("search")) {
                temp_s += string;
            }

            produceCandidates(indexPath, temp_s, resolver);
        }

    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
    }
}

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

@SuppressWarnings("static-access")
@Override//from w  w w.ja  v  a2  s .  co m
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("string").hasArg().withDescription("article title").create(TITLE_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(TITLE_OPTION) || !cmdline.hasOption(INDEX_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(FindWikipediaArticleIdHdfs.class.getName(), options);
        System.exit(-1);
    }

    String indexLocation = cmdline.getOptionValue(INDEX_OPTION);
    String title = cmdline.getOptionValue(TITLE_OPTION);

    PrintStream out = new PrintStream(System.out, true, "UTF-8");

    HdfsWikipediaSearcher searcher = new HdfsWikipediaSearcher(new Path(indexLocation), getConf());
    int id = searcher.getArticleId(title);

    out.println(title + ": id = " + id);

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

    return 0;
}

From source file:net.psexton.authzwriter.Main.java

public Main(String[] args) {
    Option reader = OptionBuilder.withArgName("reader").hasArgs()
            .withDescription("give this user read privledges").create("reader");
    Option writer = OptionBuilder.withArgName("writer").hasArgs()
            .withDescription("give this user read/write privledges").create("writer");
    Option file = OptionBuilder.withArgName("file").hasArgs().withDescription("path to output file")
            .create("file");
    Options options = new Options();
    options.addOption(reader);/*from   w w  w .j a  v  a2s  . c  o  m*/
    options.addOption(writer);
    options.addOption(file);

    CommandLineParser parser = new PosixParser();
    try {
        List<String> readers = new ArrayList<String>();
        List<String> writers = new ArrayList<String>();

        CommandLine line = parser.parse(options, args);
        if (line.hasOption("reader")) {
            // handle r case
            String[] usernames = line.getOptionValues("reader");
            readers = Arrays.asList(usernames);
        }
        if (line.hasOption("writer")) {
            // handle w case
            String[] usernames = line.getOptionValues("writer");
            writers = Arrays.asList(usernames);
        }

        String fileBody = createFileBody(readers, writers);
        if (line.hasOption("file")) {
            String filePath = line.getOptionValue("file");
            writeToFile(fileBody, filePath);
        } else {
            System.out.println(fileBody);
        }
    } catch (ParseException ex) {
        throw new RuntimeException(ex);
    }

}

From source file:io.bfscan.clueweb12.LookupWarcTrecIdMapping.java

@SuppressWarnings("static-access")
public int run(String[] args) throws Exception {
    Options options = new Options();
    options.addOption(//  w  w  w .  jav a  2 s  .  com
            OptionBuilder.withArgName("dir").hasArg().withDescription("index location").create(INDEX_OPTION));
    options.addOption(
            OptionBuilder.withArgName("id").hasArg().withDescription("WARC-TREC-ID").create(DOCID_OPTION));
    options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("docno").create(DOCNO_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(INDEX_OPTION)
            || !(cmdline.hasOption(DOCID_OPTION) || cmdline.hasOption(DOCNO_OPTION))) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(LookupWarcTrecIdMapping.class.getCanonicalName(), options);
        System.exit(-1);
    }

    String indexPath = cmdline.getOptionValue(INDEX_OPTION);

    WarcTrecIdMapping mapping = new WarcTrecIdMapping(new Path(indexPath), getConf());
    if (cmdline.hasOption(DOCID_OPTION)) {
        System.out.println(mapping.getDocno(cmdline.getOptionValue(DOCID_OPTION)));
    }

    if (cmdline.hasOption(DOCNO_OPTION)) {
        System.out.println(mapping.getDocid(Integer.parseInt(cmdline.getOptionValue(DOCNO_OPTION))));
    }

    return 0;
}