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


Java OptionBuilder.hasOptionalArg方法代码示例

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


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

示例1: createOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static Options createOptions() {
  Options options = new Options();

  OptionBuilder.withDescription("Show this help");
  options.addOption(OptionBuilder.create(CMD_HELP));

  OptionBuilder.withArgName("port");
  OptionBuilder.hasOptionalArg();
  OptionBuilder.withDescription("The port to run the Nutch Server. Default port 8081");
  options.addOption(OptionBuilder.create(CMD_PORT));

  OptionBuilder.withArgName("host");
  OptionBuilder.hasOptionalArg();
  OptionBuilder.withDescription("The host to bind the Nutch Server to. Default is localhost.");
  options.addOption(OptionBuilder.create(CMD_HOST));

  return options;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:19,代码来源:NutchServer.java

示例2: createWebAppOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static Options createWebAppOptions() {
  Options options = new Options();
  Option helpOpt = new Option("h", "help", false, "show this help message");
  OptionBuilder.withDescription("Port to run the WebApplication on.");
  OptionBuilder.hasOptionalArg();
  OptionBuilder.withArgName("port number");
  options.addOption(OptionBuilder.create(CMD_PORT));
  options.addOption(helpOpt);
  return options;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:11,代码来源:NutchUiServer.java

示例3: 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

示例4: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
static Options buildOptions(final Locale locale) {
    final ResourceBundle bundle = Setup.getResourceBundle(locale);
    final Options options = new Options();

    // help
    OptionBuilder.withLongOpt("help");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.help"));
    options.addOption(OptionBuilder.create('?'));

    // force
    OptionBuilder.withLongOpt("force");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.force"));
    options.addOption(OptionBuilder.create('f'));

    // create database
    OptionBuilder.withLongOpt("database");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.create-data-base"));
    options.addOption(OptionBuilder.create('d'));

    // export script
    OptionBuilder.withLongOpt("script");
    OptionBuilder.hasOptionalArg();
    OptionBuilder.withArgName("file");
    OptionBuilder.withDescription(bundle.getString("arg.export-script"));
    options.addOption(OptionBuilder.create('s'));

    // create basic data
    OptionBuilder.withLongOpt("basic-data");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.create-basic-data"));
    options.addOption(OptionBuilder.create('b'));

    // create initial data
    OptionBuilder.withLongOpt("initial-data");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.create-initial-data"));
    options.addOption(OptionBuilder.create('i'));

    // create sms data
    OptionBuilder.withLongOpt("sms-data");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(bundle.getString("arg.create-sms-data"));
    options.addOption(OptionBuilder.create('m'));

    return options;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:50,代码来源:Arguments.java


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