当前位置: 首页>>代码示例>>Java>>正文


Java OptionBuilder.create方法代码示例

本文整理汇总了Java中org.apache.commons.cli.OptionBuilder.create方法的典型用法代码示例。如果您正苦于以下问题:Java OptionBuilder.create方法的具体用法?Java OptionBuilder.create怎么用?Java OptionBuilder.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.cli.OptionBuilder的用法示例。


在下文中一共展示了OptionBuilder.create方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerOptionalOption

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static Option registerOptionalOption(String opt, String longOpt, String description, int numArgs) {
	Option option = OptionBuilder.create(opt);
	option.setRequired(false);
	option.setDescription("option: " + description);
	option.setLongOpt(longOpt);
	option.setArgs(numArgs);
	optionalOptionMap.put(opt, option);
	return option;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:DBToolOptions.java

示例2: registerTaskOption

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static Option registerTaskOption(String opt, String longOpt, String description, int numArgs) {
	Option option = OptionBuilder.create(opt);
	option.setRequired(false);
	option.setDescription("task: " + description);
	option.setLongOpt(longOpt);
	option.setArgs(numArgs);
	taskOptionMap.put(opt, option);
	return option;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:DBToolOptions.java

示例3: createOption

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
public static Option createOption(String shortOpt, String longOpt, String argName, boolean required,
    String description) {
  OptionBuilder optionBuilder = OptionBuilder.withLongOpt(longOpt).withDescription(description).isRequired(required);

  if (!StringUtils.isEmpty(argName)) {

    optionBuilder = optionBuilder.withArgName(argName).hasArg();
  }

  return optionBuilder.create(shortOpt);
}
 
开发者ID:srinipunuru,项目名称:samza-sql-tools,代码行数:12,代码来源:CommandLineHelper.java

示例4: initArgOption

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static void initArgOption(boolean required, String optionName, String optionArg) {
	OptionBuilder.withArgName(optionName);
	OptionBuilder.isRequired(required);
	OptionBuilder.hasArg();
	Option opt = OptionBuilder.create(optionArg);
	OPTIONS.addOption(opt);
}
 
开发者ID:boly38,项目名称:mongodbdump-java-wrapper,代码行数:8,代码来源:Main.java

示例5: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the LinkRank 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 db to use");
  Option webgraphOpts = OptionBuilder.create("webgraphdb");
  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;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:37,代码来源:LinkRank.java

示例6: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the LinkDumper tool. This simply creates the database, to read the
 * values the nested Reader tool must be used.
 */
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("LinkDumper", options);
      return -1;
    }

    String webGraphDb = line.getOptionValue("webgraphdb");
    dumpLinks(new Path(webGraphDb));
    return 0;
  } catch (Exception e) {
    LOG.error("LinkDumper: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:37,代码来源:LinkDumper.java

示例7: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Build command line options
 * 
 * @return
 */
@SuppressWarnings("static-access")
private Options buildOptions() {

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

	Option start = OptionBuilder
			.hasOptionalArg()
			.withArgName("command")
			.withDescription(
					"e.g. collector will start the collector service")
			.create("start");

	Option stop = OptionBuilder.hasOptionalArg().withArgName("command")
			.withDescription("e.g. collector will stop the collect")
			.create("stop");

	Option json = OptionBuilder.withDescription("prints to json format ")
			.create("json");

	Option coordinationStatus = OptionBuilder.create("collectorStatus");

	Options options = new Options();
	options.addOption(help);
	options.addOption(start);
	options.addOption(stop);
	options.addOption(json);
	options.addOption(coordinationStatus);

	return options;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:36,代码来源:CollectorCommandLineParser.java

示例8: parseArgs

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * parse args
 */
private static CommandLine parseArgs(Options opts, String... args)
throws IllegalArgumentException {

  OptionBuilder.withArgName("NameNode|DataNode");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("specify jmx service (NameNode by default)");
  Option jmx_service = OptionBuilder.create("service");

  OptionBuilder.withArgName("mbean server");
  OptionBuilder.hasArg();
  OptionBuilder
  .withDescription("specify mbean server (localhost by default)");
  Option jmx_server = OptionBuilder.create("server");

  OptionBuilder.withDescription("print help");
  Option jmx_help = OptionBuilder.create("help");

  OptionBuilder.withArgName("mbean server port");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("specify mbean server port, "
      + "if missing - it will try to connect to MBean Server in the same VM");
  Option jmx_port = OptionBuilder.create("port");

  OptionBuilder.withArgName("VM's connector url");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("connect to the VM on the same machine;"
      + "\n use:\n jstat -J-Djstat.showUnsupported=true -snap <vmpid> | "
      + "grep sun.management.JMXConnectorServer.address\n "
      + "to find the url");
  Option jmx_localVM = OptionBuilder.create("localVM");

  opts.addOption(jmx_server);
  opts.addOption(jmx_help);
  opts.addOption(jmx_service);
  opts.addOption(jmx_port);
  opts.addOption(jmx_localVM);

  CommandLine commandLine = null;
  CommandLineParser parser = new GnuParser();
  try {
    commandLine = parser.parse(opts, args, true);
  } catch (ParseException e) {
    printUsage(opts);
    throw new IllegalArgumentException("invalid args: " + e.getMessage());
  }
  return commandLine;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:JMXGet.java

示例9: main

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the resolve urls tool.
 */
public static void main(String[] args) {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("urls");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the urls file to check");
  Option urlOpts = OptionBuilder.create("urls");
  options.addOption(urlOpts);

  OptionBuilder.withArgName("numThreads");
  OptionBuilder.hasArgs();
  OptionBuilder.withDescription("the number of threads to use");
  Option numThreadOpts = OptionBuilder.create("numThreads");
  options.addOption(numThreadOpts);

  CommandLineParser parser = new GnuParser();
  try {
    // parse out common line arguments
    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("urls")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("ResolveUrls", options);
      return;
    }

    // get the urls and the number of threads and start the resolver
    String urls = line.getOptionValue("urls");
    int numThreads = 100;
    String numThreadsStr = line.getOptionValue("numThreads");
    if (numThreadsStr != null) {
      numThreads = Integer.parseInt(numThreadsStr);
    }
    ResolveUrls resolve = new ResolveUrls(urls, numThreads);
    resolve.resolveUrls();
  } catch (Exception e) {
    LOG.error("ResolveUrls: " + StringUtils.stringifyException(e));
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:47,代码来源:ResolveUrls.java

示例10: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the ScoreUpdater 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("crawldb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the crawldb to use");
  Option crawlDbOpts = OptionBuilder.create("crawldb");
  options.addOption(crawlDbOpts);

  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the webgraphdb to use");
  Option webGraphOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphOpts);

  CommandLineParser parser = new GnuParser();
  try {

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

    String crawlDb = line.getOptionValue("crawldb");
    String webGraphDb = line.getOptionValue("webgraphdb");
    update(new Path(crawlDb), new Path(webGraphDb));
    return 0;
  } catch (Exception e) {
    LOG.error("ScoreUpdater: " + StringUtils.stringifyException(e));
    return -1;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:44,代码来源:ScoreUpdater.java

示例11: main

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the NodeReader tool. The command line arguments must contain a
 * webgraphdb path and a url. The url must match the normalized url that is
 * contained in the NodeDb of the WebGraph.
 */
public static void main(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 webgraphdb to use");
  Option webGraphOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphOpts);

  OptionBuilder.withArgName("url");
  OptionBuilder.hasOptionalArg();
  OptionBuilder.withDescription("the url to dump");
  Option urlOpts = OptionBuilder.create("url");
  options.addOption(urlOpts);

  CommandLineParser parser = new GnuParser();
  try {

    // command line must take a webgraphdb and a url
    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")
        || !line.hasOption("url")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("WebGraphReader", options);
      return;
    }

    // dump the values to system out and return
    String webGraphDb = line.getOptionValue("webgraphdb");
    String url = line.getOptionValue("url");
    NodeReader reader = new NodeReader(NutchConfiguration.create());
    reader.dumpUrl(new Path(webGraphDb), url);

    return;
  } catch (Exception e) {
    e.printStackTrace();
    return;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:50,代码来源:NodeReader.java

示例12: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Build command line options
 * 
 * @return
 */
@SuppressWarnings("static-access")
private Options buildOptions() {

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

	Option ls = OptionBuilder.hasOptionalArg().create("ls");

	Option start = OptionBuilder
			.hasOptionalArg()
			.withArgName("command")
			.withDescription(
					"e.g. coordination will start the coordination service")
			.create("start");

	Option stop = OptionBuilder.hasOptionalArg().withArgName("command")
			.withDescription("e.g. coordination will stop the coordination")
			.create("stop");

	Option agent = OptionBuilder.hasOptionalArg().withArgName("agentName")
	.withDescription("when provided with the ls command a list of agent names is provided, with the count command the count of the number of agents is provided")
	.create("agent");

	Option logType = OptionBuilder
	.withDescription("when provided with the ls command a list of agent names is provided, with the count command the count of the number of agents is provided")
	.create("logType");

	
	Option count = OptionBuilder.hasOptionalArg().create("count");

	Option from = OptionBuilder.hasArg().withArgName("from")
			.withDescription("from position (integer)").create("from");

	Option maxResults = OptionBuilder.hasArg().withArgName("max")
			.withDescription("max results position (integer)")
			.create("max");
	
	Option offline = OptionBuilder
			.withDescription(
					"Use only when the coordination is not running use with ls, status, update to connect to the database directory and not via rest")
			.create("o");

	Option json = OptionBuilder.withDescription("prints to json format ")
			.create("json");

	Option coordinationStatus = OptionBuilder
			.create("coordinationStatus");

	Option query = OptionBuilder
			.hasArg()
			.withArgName("query")
			.withDescription(
					"jpa query string e.g. lastModificationTime < 1000")
			.create("query");

	Options options = new Options();
	options.addOption(help);
	options.addOption(start);
	options.addOption(stop);
	options.addOption(ls);
	options.addOption(agent);
	options.addOption(logType);
	options.addOption(count);
	options.addOption(from);
	options.addOption(maxResults);
	options.addOption(json);
	options.addOption(query);
	options.addOption(offline);
	options.addOption(coordinationStatus);

	return options;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:77,代码来源:CoordinationCommandLineParser.java


注:本文中的org.apache.commons.cli.OptionBuilder.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。