本文整理汇总了Java中org.apache.commons.cli.CommandLine.getOptionProperties方法的典型用法代码示例。如果您正苦于以下问题:Java CommandLine.getOptionProperties方法的具体用法?Java CommandLine.getOptionProperties怎么用?Java CommandLine.getOptionProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.cli.CommandLine
的用法示例。
在下文中一共展示了CommandLine.getOptionProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
protected void parse(CommandLine commandLine) {
super.parse(commandLine);
this.scriptName = commandLine.getOptionValue("n");
this.scriptVersionId = commandLine.getOptionValue("v");
this.input = commandLine.getOptionProperties("p");
if (this.input.isEmpty()) {
this.input = null;
}
}
示例2: parse
import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
@Override
protected void parse(CommandLine commandLine) {
super.parse(commandLine);
this.scriptExecutionId = commandLine.getOptionValue("seid");
this.executionId = commandLine.getOptionValue("eid");
this.resultProperties = commandLine.getOptionProperties("p");
}
示例3: parseCommandLineOpts
import org.apache.commons.cli.CommandLine; //导入方法依赖的package包/类
private boolean parseCommandLineOpts(String[] args) throws ParseException {
Options options = new Options();
options.addOption("l", "dataDirs", true, "Comma-separated list of data " +
"directories which the tool must verify. This option is mandatory")
.addOption("h", "help", false, "Display help")
.addOption("e", "eventValidator", true,
"Fully Qualified Name of Event Validator Implementation");
Option property = OptionBuilder.withArgName("property=value")
.hasArgs(2)
.withValueSeparator()
.withDescription("custom properties")
.create("D");
options.addOption(property);
CommandLineParser parser = new GnuParser();
CommandLine commandLine = parser.parse(options, args);
if (commandLine.hasOption("help")) {
new HelpFormatter().printHelp("bin/flume-ng tool fcintegritytool ", options, true);
return false;
}
if (!commandLine.hasOption("dataDirs")) {
new HelpFormatter().printHelp("bin/flume-ng tool fcintegritytool ", "",
options, "dataDirs is required.", true);
return false;
} else {
String[] dataDirStr = commandLine.getOptionValue("dataDirs").split(",");
for (String dataDir : dataDirStr) {
File f = new File(dataDir);
if (!f.exists()) {
throw new FlumeException("Data directory, " + dataDir + " does not exist.");
}
dataDirs.add(f);
}
}
if (commandLine.hasOption("eventValidator")) {
try {
Class<? extends EventValidator.Builder> eventValidatorClassName =
(Class<? extends EventValidator.Builder>)Class.forName(
commandLine.getOptionValue("eventValidator"));
EventValidator.Builder eventValidatorBuilder = eventValidatorClassName.newInstance();
// Pass on the configuration parameter
Properties systemProperties = commandLine.getOptionProperties("D");
Context context = new Context();
Set<String> keys = systemProperties.stringPropertyNames();
for (String key : keys) {
context.put(key, systemProperties.getProperty(key));
}
eventValidatorBuilder.configure(context);
eventValidator = eventValidatorBuilder.build();
} catch (Exception e) {
System.err.println(String.format("Could find class %s in lib folder",
commandLine.getOptionValue("eventValidator")));
e.printStackTrace();
return false;
}
}
return true;
}