当前位置: 首页>>代码示例>>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;未经允许,请勿转载。