本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}