本文整理匯總了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;
}