org.apache.commons.cli.Option#setType ( )源码实例Demo

下面列出了org.apache.commons.cli.Option#setType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: datawave   文件: OptionBuilder.java
/**
 * Creates an Option using OptionBuilder's State and the given parameters.
 *
 * @param opt
 *            short representation of the option
 * @param longOpt
 *            long representation of the option
 * @param desc
 *            descibes the function of the option
 * @return the new Option
 */
public Option create(final String opt, final String longOpt, final String desc) {
    final Option option = new Option(opt, desc);
    option.setLongOpt(longOpt);
    option.setArgs(args);
    option.setRequired(required);
    option.setOptionalArg(optionalArg);
    option.setType(type);
    option.setValueSeparator(valSeparator);
    
    return option;
}
 
/**
 * Create the options available for the DistributedTestDriver
 * 
 * @return Apache's CLI Options object
 */
private Options createOptions()
{
  Options options = new Options();

  // help
  Option optionHelp = new Option("h", "help", false, "Print out the help documentation for this command line execution");
  optionHelp.setRequired(false);
  options.addOption(optionHelp);

  // jar file
  Option optionJar = new Option("j", "jar", true, "required -- Fully qualified jar file");
  optionJar.setRequired(false);
  options.addOption(optionJar);

  // test selection
  String tests = "testNum = 1: Wideskies Tests\n";
  tests += "Subtests:\n";
  tests += "E - Elasticsearch MapReduce\n";
  tests += "J - JSON/HDFS MapReduce\n";
  tests += "ES - Elasticsearch Spark \n";
  tests += "JS - JSON/HDFS Spark \n";
  tests += "SS - Spark Streaming Tests \n";
  tests += "JSS - JSON/HDFS Spark Streaming \n";
  tests += "ESS - Elasticsearch Spark Streaming \n";

  Option optionTestSelection = new Option("t", "tests", true, "optional -- Select which tests to execute: \n" + tests);
  optionTestSelection.setRequired(false);
  optionTestSelection.setArgName("<testNum>:<subtestDesignator>");
  optionTestSelection.setType(String.class);
  options.addOption(optionTestSelection);

  return options;
}
 
源代码3 项目: incubator-heron   文件: AbstractTestTopology.java
protected Options getArgOptions() {
  Options options = new Options();

  Option topologyNameOption = new Option("t", TOPOLOGY_OPTION, true, "topology name");
  topologyNameOption.setRequired(true);
  options.addOption(topologyNameOption);

  Option resultsUrlOption =
      new Option("r", RESULTS_URL_OPTION, true, "url to post and get test data");
  resultsUrlOption.setRequired(true);
  options.addOption(resultsUrlOption);

  Option stateUrlOption =
      new Option("s", STATE_URL_OPTION, true, "url to post and get test state info");
  stateUrlOption.setRequired(true);
  options.addOption(stateUrlOption);

  Option stateTokenOption = new Option("u", STATE_UPDATE_TOKEN, true,
      "state server token to use for spout http condition triggers");
  stateTokenOption.setRequired(false);
  options.addOption(stateTokenOption);

  Option spoutWrapperOption = new Option("S", SPOUT_WRAPPER_TOKEN, true,
      "What type of spout wrapper to use");
  spoutWrapperOption.setType(TestTopologyBuilder.SpoutWrapperType.class);
  spoutWrapperOption.setRequired(false);
  options.addOption(spoutWrapperOption);

  return options;
}
 
源代码4 项目: incubator-heron   文件: HeronInstance.java
private static CommandLine parseCommandLineArgs(String[] args) {
  Options options = new Options();

  Option topologyNameOption = new Option(
      CommandLineOptions.TOPOLOGY_NAME_OPTION, true, "Topology Name");
  topologyNameOption.setRequired(true);
  topologyNameOption.setType(String.class);
  options.addOption(topologyNameOption);

  Option topologyIdOption = new Option(
      CommandLineOptions.TOPOLOGY_ID_OPTION, true, "Topology ID");
  topologyIdOption.setRequired(true);
  topologyIdOption.setType(String.class);
  options.addOption(topologyIdOption);

  Option instanceIdOption = new Option(
      CommandLineOptions.INSTANCE_ID_OPTION, true, "Instance ID");
  instanceIdOption.setRequired(true);
  instanceIdOption.setType(String.class);
  options.addOption(instanceIdOption);

  Option componentNameOption = new Option(
      CommandLineOptions.COMPONENT_NAME_OPTION, true, "Component Name");
  componentNameOption.setRequired(true);
  componentNameOption.setType(String.class);
  options.addOption(componentNameOption);

  Option taskIdOption = new Option(CommandLineOptions.TASK_ID_OPTION, true, "Task ID");
  taskIdOption.setRequired(true);
  taskIdOption.setType(Integer.class);
  options.addOption(taskIdOption);

  Option componentIndexOption = new Option(
      CommandLineOptions.COMPONENT_INDEX_OPTION, true, "Component Index");
  componentIndexOption.setRequired(true);
  componentIndexOption.setType(Integer.class);
  options.addOption(componentIndexOption);

  Option stmgrIdOption = new Option(
      CommandLineOptions.STMGR_ID_OPTION, true, "Stream Manager ID");
  stmgrIdOption.setType(String.class);
  stmgrIdOption.setRequired(true);
  options.addOption(stmgrIdOption);

  Option stmgrPortOption = new Option(
      CommandLineOptions.STMGR_PORT_OPTION, true, "Stream Manager Port");
  stmgrPortOption.setType(Integer.class);
  stmgrPortOption.setRequired(true);
  options.addOption(stmgrPortOption);

  Option metricsmgrPortOption = new Option(
      CommandLineOptions.METRICS_MGR_PORT_OPTION, true, "Metrics Manager Port");
  metricsmgrPortOption.setType(Integer.class);
  metricsmgrPortOption.setRequired(true);
  options.addOption(metricsmgrPortOption);

  Option systemConfigFileOption = new Option(
      CommandLineOptions.SYSTEM_CONFIG_FILE, true, "Heron Internals Config Filename");
  systemConfigFileOption.setType(String.class);
  systemConfigFileOption.setRequired(true);
  options.addOption(systemConfigFileOption);

  Option overrideConfigFileOption
      = new Option(CommandLineOptions.OVERRIDE_CONFIG_FILE,
      true, "Override Config File");
  overrideConfigFileOption.setType(String.class);
  overrideConfigFileOption.setRequired(true);
  options.addOption(overrideConfigFileOption);

  Option remoteDebuggerPortOption = new Option(
      CommandLineOptions.REMOTE_DEBUGGER_PORT, true, "Remote Debugger Port");
  remoteDebuggerPortOption.setType(Integer.class);
  options.addOption(remoteDebuggerPortOption);

  CommandLineParser parser = new DefaultParser();
  HelpFormatter formatter = new HelpFormatter();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, args);
  } catch (ParseException e) {
    System.out.println(e.getMessage());
    formatter.printHelp("Heron Instance", options);
    throw new RuntimeException("Incorrect Usage");
  }
  return cmd;
}
 
源代码5 项目: ignite   文件: GridVmNodesStarter.java
/**
 * Creates cli options.
 *
 * @return Command line options
 */
private static Options createOptions() {
    Options options = new Options();

    OptionGroup grp = new OptionGroup();

    grp.setRequired(true);

    Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file.");

    cfg.setArgName("file");

    Option n = new Option(null, OPTION_N, true, "nodes count.");

    n.setValueSeparator('=');
    n.setType(Integer.class);

    grp.addOption(cfg);
    grp.addOption(n);

    options.addOptionGroup(grp);

    return options;
}
 
源代码6 项目: ignite   文件: GridRandomCommandLineLoader.java
/**
 * Creates cli options.
 *
 * @return Command line options
 */
private static Options createOptions() {
    Options options = new Options();

    Option help = new Option(OPTION_HELP, "print this message");

    Option cfg = new Option(null, OPTION_CFG, true, "path to Spring XML configuration file.");

    cfg.setValueSeparator('=');
    cfg.setType(String.class);

    Option minTtl = new Option(null, OPTION_MIN_TTL, true, "node minimum time to live.");

    minTtl.setValueSeparator('=');
    minTtl.setType(Long.class);

    Option maxTtl = new Option(null, OPTION_MAX_TTL, true, "node maximum time to live.");

    maxTtl.setValueSeparator('=');
    maxTtl.setType(Long.class);

    Option duration = new Option(null, OPTION_DURATION, true, "run timeout.");

    duration.setValueSeparator('=');
    duration.setType(Long.class);

    Option log = new Option(null, OPTION_LOG_CFG, true, "path to log4j configuration file.");

    log.setValueSeparator('=');
    log.setType(String.class);

    options.addOption(help);

    OptionGroup grp = new OptionGroup();

    grp.setRequired(true);

    grp.addOption(cfg);
    grp.addOption(minTtl);
    grp.addOption(maxTtl);
    grp.addOption(duration);
    grp.addOption(log);

    options.addOptionGroup(grp);

    return options;
}