當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandLine.getOptionProperties方法代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:11,代碼來源:Start.java

示例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");
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:8,代碼來源:End.java

示例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;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:64,代碼來源:FileChannelIntegrityTool.java


注:本文中的org.apache.commons.cli.CommandLine.getOptionProperties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。