Java Code Examples for org.apache.commons.cli.Options#addOptionGroup()

The following examples show how to use org.apache.commons.cli.Options#addOptionGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CLIParser.java    From bcrypt with Apache License 2.0 6 votes vote down vote up
static Options setupOptions() {
    Options options = new Options();
    Option optHash = Option.builder(ARG_HASH).longOpt("bhash").argName("cost> <[16-hex-byte-salt]").hasArgs().desc("Use this flag if you want to compute the bcrypt hash. Pass the logarithm cost factor (4-31) and optionally the used salt" +
            " as hex encoded byte array (must be exactly 16 bytes/32 characters hex). Example: '--bhash 12 8e270d6129fd45f30a9b3fe44b4a8d9a'").required().build();
    Option optCheck = Option.builder(ARG_CHECK).longOpt("check").argName("bcrypt-hash").hasArg().desc("Use this flag if you want to verify a hash against a given password. Example: '--check $2a$06$If6bvum7DFjUnE9p2uDeDu0YHzrHM6tf.iqN8.yx.jNN1ILEf7h0i'").build();

    Option help = Option.builder("h").longOpt("help").desc("Prints help docs.").build();
    Option version = Option.builder("v").longOpt("version").desc("Prints current version.").build();

    OptionGroup mainArgs = new OptionGroup();
    mainArgs.addOption(optCheck).addOption(optHash).addOption(help).addOption(version);
    mainArgs.setRequired(true);

    options.addOptionGroup(mainArgs);
    return options;
}
 
Example 2
Source File: JobCommand.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
private Options createCommandLineOptions() {
    Options options = new Options();

    OptionGroup actionGroup = new OptionGroup();
    actionGroup.addOption(new Option("h", HELP_OPT, false, "Shows the help message."));
    actionGroup.addOption(new Option("d", DETAILS_OPT, false, "Show details about a job/task."));
    actionGroup.addOption(new Option("l", LIST_OPT, false, "List jobs/tasks."));
    actionGroup.addOption(new Option("p", PROPS_OPT, false, "Fetch properties with the query."));
    actionGroup.setRequired(true);
    options.addOptionGroup(actionGroup);

    OptionGroup idGroup = new OptionGroup();
    idGroup.addOption(new Option("j", NAME_OPT, true, "Find job(s) matching given job name."));
    idGroup.addOption(new Option("i", ID_OPT, true, "Find the job/task with the given id."));
    options.addOptionGroup(idGroup);

    options.addOption("n", true, "Limit the number of results returned. (default:" + DEFAULT_RESULTS_LIMIT + ")");
    options.addOption("r", RECENT_OPT, false, "List the most recent jobs (instead of a list of unique jobs)");
    options.addOption("H", ADMIN_SERVER, true, "hostname of admin server");
    options.addOption("P", ADMIN_PORT, true, "port of admin server");

    return options;
}
 
Example 3
Source File: CommandLineParser.java    From DroidRA with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Populates the default command line arguments that are common to all analyses.
 * 
 * @param options The command line options object that should be modified.
 */
private void parseDefaultCommandLineArguments(Options options) {
  OptionGroup modelGroup = new OptionGroup();
  modelGroup.addOption(Option.builder("model").desc("Path to the model directory.").hasArg()
      .argName("model directory").build());
  modelGroup.addOption(Option.builder("cmodel").desc("Path to the compiled model.").hasArg()
      .argName("compiled model").build());
  modelGroup.setRequired(false);

  options.addOptionGroup(modelGroup);

  options.addOption(Option.builder("cp").desc("The classpath for the analysis.").hasArg()
      .argName("classpath").required().longOpt("classpath").build());
  options.addOption(Option.builder("in").desc("The input code for the analysis.").hasArg()
      .argName("input").required().longOpt("input").build());
  options.addOption(Option.builder("out").desc("The output directory or file.").hasArg()
      .argName("output").longOpt("output").build());
  options.addOption(Option.builder("traversemodeled").desc("Propagate through modeled classes.")
      .hasArg(false).build());
  options.addOption("modeledtypesonly", false, "Only infer modeled types.");
  options.addOption(Option.builder("threadcount")
      .desc("The maximum number of threads that should be used.").hasArg()
      .argName("thread count").type(Number.class).build());
}
 
Example 4
Source File: Main.java    From yangtools with Eclipse Public License 1.0 6 votes vote down vote up
private static Options createOptions() {
    final Options options = new Options();
    options.addOption(HELP);
    options.addOption(PATH);
    options.addOption(RECURSIVE);

    final OptionGroup verbosity = new OptionGroup();
    verbosity.addOption(DEBUG);
    verbosity.addOption(QUIET);
    verbosity.addOption(VERBOSE);
    options.addOptionGroup(verbosity);

    options.addOption(OUTPUT);
    options.addOption(MODULE_NAME);
    options.addOption(FEATURE);
    return options;
}
 
Example 5
Source File: CubeMigrationCrossClusterCLI.java    From kylin with Apache License 2.0 6 votes vote down vote up
public CubeMigrationCrossClusterCLI() {
    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_HYBRID);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.addOption(OPTION_All);
    realizationOrProject.setRequired(true);

    options = new Options();
    options.addOption(OPTION_KYLIN_URI_SRC);
    options.addOption(OPTION_KYLIN_URI_DST);
    options.addOption(OPTION_FS_HA_ENABLED_CODE);
    options.addOption(OPTION_UPDATE_MAPPING);
    options.addOptionGroup(realizationOrProject);
    options.addOption(OPTION_DST_HIVE_CHECK);
    options.addOption(OPTION_SCHEMA_ONLY);
    options.addOption(OPTION_OVERWRITE);
    options.addOption(OPTION_EXECUTE);
    options.addOption(OPTION_COPROCESSOR_PATH);
    options.addOption(OPTION_DISTCP_JOB_QUEUE);
    options.addOption(OPTION_THREAD_NUM);
    options.addOption(OPTION_DISTCP_JOB_MEMORY);
}
 
Example 6
Source File: DashboardArguments.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
private static Options configureOptions() {
  Options options = new Options();
  OptionGroup inputGroup = new OptionGroup();
  inputGroup.setRequired(true);

  Option inputFileOption =
      Option.builder("f").longOpt("bom-file").hasArg().desc("File to a BOM (pom.xml)").build();
  inputGroup.addOption(inputFileOption);

  Option inputCoordinatesOption =
      Option.builder("c")
          .longOpt("bom-coordinates")
          .hasArg()
          .desc(
              "Maven coordinates of a BOM. For example, com.google.cloud:libraries-bom:1.0.0")
          .build();
  inputGroup.addOption(inputCoordinatesOption);

  Option versionlessCoordinatesOption =
      Option.builder("a")
          .longOpt("all-versions")
          .hasArg()
          .desc(
              "Maven coordinates of a BOM without version. "
                  + "For example, com.google.cloud:libraries-bom")
          .build();
  inputGroup.addOption(versionlessCoordinatesOption);

  options.addOptionGroup(inputGroup);
  return options;
}
 
Example 7
Source File: OptionManager.java    From openapi-style-validator with Apache License 2.0 5 votes vote down vote up
OptionManager() {
    options = new Options();

    OptionGroup mutualExclusiveOptions = new OptionGroup();
    Option help = new Option(HELP_OPT_SHORT,
            HELP_OPT_LONG,
            false,
            "Show help");

    Option version = new Option(VERSION_OPT_SHORT,
            VERSION_OPT_LONG,
            false,
            "Show current version");

    Option source = new Option(SOURCE_OPT_SHORT,
            SOURCE_OPT_LONG,
            true,
            "Path to your yaml or json swagger/openApi spec file");

    mutualExclusiveOptions.addOption(help);
    mutualExclusiveOptions.addOption(version);
    mutualExclusiveOptions.addOption(source);

    Option optionFile = new Option(OPTIONS_OPT_SHORT,
            OPTIONS_OPT_LONG,
            true,
            "Path to the json file containing the options");

    options.addOption(optionFile);
    options.addOptionGroup(mutualExclusiveOptions);
}
 
Example 8
Source File: CliToolConfig.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
void populate(Options options) {
    OptionGroup verbosityGroup = new OptionGroup();
    verbosityGroup.setRequired(false);
    verbosityGroup.addOption(new OptionBuilder("s", "silent").required(false).build());
    verbosityGroup.addOption(new OptionBuilder("v", "verbose").required(false).build());
    options.addOptionGroup(verbosityGroup);
}
 
Example 9
Source File: BamSlicerApplication.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
private static Options createOptions() {
    Options options = new Options();
    OptionGroup inputModeOptionGroup = new OptionGroup();
    inputModeOptionGroup.addOption(Option.builder(INPUT_MODE_S3).required().desc("read input BAM from s3").build());
    inputModeOptionGroup.addOption(Option.builder(INPUT_MODE_FILE).required().desc("read input BAM from file").build());
    inputModeOptionGroup.addOption(Option.builder(INPUT_MODE_URL).required().desc("read input BAM from url").build());
    options.addOptionGroup(inputModeOptionGroup);
    return options;
}
 
Example 10
Source File: ZkGrep.java    From helix with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
  Option zkCfgOption =
      OptionBuilder.hasArgs(1).isRequired(false).withLongOpt(zkCfg).withArgName("zoo.cfg")
          .withDescription("provide zoo.cfg").create();

  Option patternOption =
      OptionBuilder.hasArgs().isRequired(true).withLongOpt(pattern)
          .withArgName("grep-patterns...").withDescription("provide patterns (required)")
          .create();

  Option betweenOption =
      OptionBuilder.hasArgs(2).isRequired(false).withLongOpt(between)
          .withArgName("t1 t2 (timestamp in ms or yyMMdd_hhmmss_SSS)")
          .withDescription("grep between t1 and t2").create();

  Option byOption =
      OptionBuilder.hasArgs(1).isRequired(false).withLongOpt(by)
          .withArgName("t (timestamp in ms or yyMMdd_hhmmss_SSS)").withDescription("grep by t")
          .create();

  OptionGroup group = new OptionGroup();
  group.setRequired(true);
  group.addOption(betweenOption);
  group.addOption(byOption);

  Options options = new Options();
  options.addOption(zkCfgOption);
  options.addOption(patternOption);
  options.addOptionGroup(group);
  return options;
}
 
Example 11
Source File: TaskAdmin.java    From helix with Apache License 2.0 5 votes vote down vote up
/** Constructs options set for all basic control messages */
private static Options constructOptions() {
  Options options = new Options();
  options.addOptionGroup(contructGenericRequiredOptionGroup());
  options.addOptionGroup(constructStartOptionGroup());
  return options;
}
 
Example 12
Source File: ExampleProcess.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
          .create();

  Option zkServerOption =
      OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create();
  zkServerOption.setArgs(1);
  zkServerOption.setRequired(true);
  zkServerOption.setArgName("ZookeeperServerAddress(Required)");

  Option clusterOption =
      OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
  clusterOption.setArgs(1);
  clusterOption.setRequired(true);
  clusterOption.setArgName("Cluster name (Required)");

  Option hostOption =
      OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create();
  hostOption.setArgs(1);
  hostOption.setRequired(true);
  hostOption.setArgName("Host name (Required)");

  Option portOption =
      OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create();
  portOption.setArgs(1);
  portOption.setRequired(true);
  portOption.setArgName("Host port (Required)");

  Option stateModelOption =
      OptionBuilder.withLongOpt(stateModel).withDescription("StateModel Type").create();
  stateModelOption.setArgs(1);
  stateModelOption.setRequired(true);
  stateModelOption.setArgName("StateModel Type (Required)");

  // add an option group including either --zkSvr or --configFile
  Option fileOption =
      OptionBuilder.withLongOpt(configFile)
          .withDescription("Provide file to read states/messages").create();
  fileOption.setArgs(1);
  fileOption.setRequired(true);
  fileOption.setArgName("File to read states/messages (Optional)");

  Option transDelayOption =
      OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay").create();
  transDelayOption.setArgs(1);
  transDelayOption.setRequired(false);
  transDelayOption.setArgName("Delay time in state transition, in MS");

  OptionGroup optionGroup = new OptionGroup();
  optionGroup.addOption(zkServerOption);
  optionGroup.addOption(fileOption);

  Options options = new Options();
  options.addOption(helpOption);
  // options.addOption(zkServerOption);
  options.addOption(clusterOption);
  options.addOption(hostOption);
  options.addOption(portOption);
  options.addOption(stateModelOption);
  options.addOption(transDelayOption);

  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 13
Source File: DMLOptions.java    From systemds with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static Options createCLIOptions() {
	Options options = new Options();
	Option nvargsOpt = OptionBuilder.withArgName("key=value")
		.withDescription("parameterizes DML script with named parameters of the form <key=value>; <key> should be a valid identifier in DML/PyDML")
		.hasArgs().create("nvargs");
	Option argsOpt = OptionBuilder.withArgName("argN")
		.withDescription("specifies positional parameters; first value will replace $1 in DML program; $2 will replace 2nd and so on")
		.hasArgs().create("args");
	Option configOpt = OptionBuilder.withArgName("filename")
		.withDescription("uses a given configuration file (can be on local/hdfs/gpfs; default values in SystemDS-config.xml")
		.hasArg().create("config");
	Option cleanOpt = OptionBuilder.withDescription("cleans up all SystemDS working directories (FS, DFS); all other flags are ignored in this mode.")
		.create("clean");
	Option statsOpt = OptionBuilder.withArgName("count")
		.withDescription("monitors and reports summary execution statistics; heavy hitter <count> is 10 unless overridden; default off")
		.hasOptionalArg().create("stats");
	Option memOpt = OptionBuilder.withDescription("monitors and reports max memory consumption in CP; default off")
		.create("mem");
	Option explainOpt = OptionBuilder.withArgName("level")
		.withDescription("explains plan levels; can be 'hops' / 'runtime'[default] / 'recompile_hops' / 'recompile_runtime'")
		.hasOptionalArg().create("explain");
	Option execOpt = OptionBuilder.withArgName("mode")
		.withDescription("sets execution mode; can be 'hadoop' / 'singlenode' / 'hybrid'[default] / 'HYBRID' / 'spark'")
		.hasArg().create("exec");
	Option gpuOpt = OptionBuilder.withArgName("force")
		.withDescription("uses CUDA instructions when reasonable; set <force> option to skip conservative memory estimates and use GPU wherever possible; default off")
		.hasOptionalArg().create("gpu");
	Option debugOpt = OptionBuilder.withDescription("runs in debug mode; default off")
		.create("debug");
	Option pythonOpt = OptionBuilder.withDescription("parses Python-like DML")
		.create("python");
	Option fileOpt = OptionBuilder.withArgName("filename")
		.withDescription("specifies dml/pydml file to execute; path can be local/hdfs/gpfs (prefixed with appropriate URI)")
		.isRequired().hasArg().create("f");
	Option scriptOpt = OptionBuilder.withArgName("script_contents")
		.withDescription("specified script string to execute directly")
		.isRequired().hasArg().create("s");
	Option helpOpt = OptionBuilder.withDescription("shows usage message")
		.create("help");
	Option lineageOpt = OptionBuilder.withDescription("computes lineage traces")
		.hasOptionalArgs().create("lineage");
	Option fedOpt = OptionBuilder.withDescription("starts a federated worker with the given argument as the port.")
		.hasOptionalArg().create("w");
	
	options.addOption(configOpt);
	options.addOption(cleanOpt);
	options.addOption(statsOpt);
	options.addOption(memOpt);
	options.addOption(explainOpt);
	options.addOption(execOpt);
	options.addOption(gpuOpt);
	options.addOption(debugOpt);
	options.addOption(pythonOpt);
	options.addOption(lineageOpt);
	options.addOption(fedOpt);

	// Either a clean(-clean), a file(-f), a script(-s) or help(-help) needs to be specified
	OptionGroup fileOrScriptOpt = new OptionGroup()
		.addOption(scriptOpt)
		.addOption(fileOpt)
		.addOption(cleanOpt)
		.addOption(helpOpt)
		.addOption(fedOpt);
	fileOrScriptOpt.setRequired(true);
	options.addOptionGroup(fileOrScriptOpt);
	
	// Either -args or -nvargs
	options.addOptionGroup(new OptionGroup()
		.addOption(nvargsOpt).addOption(argsOpt));
	options.addOption(helpOpt);
	
	return options;
}
 
Example 14
Source File: BootstrapProcess.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
          .create();

  Option zkServerOption =
      OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create();
  zkServerOption.setArgs(1);
  zkServerOption.setRequired(true);
  zkServerOption.setArgName("ZookeeperServerAddress(Required)");

  Option clusterOption =
      OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
  clusterOption.setArgs(1);
  clusterOption.setRequired(true);
  clusterOption.setArgName("Cluster name (Required)");

  Option hostOption =
      OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create();
  hostOption.setArgs(1);
  hostOption.setRequired(true);
  hostOption.setArgName("Host name (Required)");

  Option portOption =
      OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create();
  portOption.setArgs(1);
  portOption.setRequired(true);
  portOption.setArgName("Host port (Required)");

  Option stateModelOption =
      OptionBuilder.withLongOpt(stateModel).withDescription("StateModel Type").create();
  stateModelOption.setArgs(1);
  stateModelOption.setRequired(true);
  stateModelOption.setArgName("StateModel Type (Required)");

  // add an option group including either --zkSvr or --configFile
  Option fileOption =
      OptionBuilder.withLongOpt(configFile)
          .withDescription("Provide file to read states/messages").create();
  fileOption.setArgs(1);
  fileOption.setRequired(true);
  fileOption.setArgName("File to read states/messages (Optional)");

  Option transDelayOption =
      OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay").create();
  transDelayOption.setArgs(1);
  transDelayOption.setRequired(false);
  transDelayOption.setArgName("Delay time in state transition, in MS");

  OptionGroup optionGroup = new OptionGroup();
  optionGroup.addOption(zkServerOption);
  optionGroup.addOption(fileOption);

  Options options = new Options();
  options.addOption(helpOption);
  // options.addOption(zkServerOption);
  options.addOption(clusterOption);
  options.addOption(hostOption);
  options.addOption(portOption);
  options.addOption(stateModelOption);
  options.addOption(transDelayOption);

  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 15
Source File: MigrationHelper.java    From java-samples with Apache License 2.0 4 votes vote down vote up
static Options buildOptions() {
  Options options = new Options();

  Option generateReport =
      Option.builder(MigrationOptions.GENERATE_REPORT.option)
          .longOpt(MigrationOptions.GENERATE_REPORT.longOpt)
          .desc(MigrationOptions.GENERATE_REPORT.description)
          .build();

  Option duplicateHolds =
      Option.builder(MigrationOptions.DUPLICATE_HOLDS.option)
          .longOpt(MigrationOptions.DUPLICATE_HOLDS.longOpt)
          .desc(MigrationOptions.DUPLICATE_HOLDS.description)
          .build();

  Option reportFile =
      Option.builder(MigrationOptions.REPORT_FILE.option)
          .required()
          .hasArg()
          .longOpt(MigrationOptions.REPORT_FILE.longOpt)
          .argName("reportfile")
          .desc(MigrationOptions.REPORT_FILE.description)
          .build();

  Option errorFile =
      Option.builder(MigrationOptions.ERROR_FILE.option)
          .required()
          .hasArg()
          .longOpt(MigrationOptions.ERROR_FILE.longOpt)
          .argName("errorfile")
          .desc(MigrationOptions.ERROR_FILE.description)
          .build();

  Option includeRoom =
      Option.builder(MigrationOptions.INCLUDE_ROOMS.option)
          .longOpt(MigrationOptions.INCLUDE_ROOMS.longOpt)
          .argName(MigrationOptions.INCLUDE_ROOMS.description)
          .desc(MigrationOptions.INCLUDE_ROOMS.description)
          .build();

  options.addOption(reportFile);
  options.addOption(errorFile);
  options.addOption(includeRoom);

  OptionGroup optionGroup = new OptionGroup();
  optionGroup.addOption(generateReport).addOption(duplicateHolds).addOption(helpOption);
  optionGroup.setRequired(true);
  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 16
Source File: RegressionTests.java    From quandl4j with Apache License 2.0 4 votes vote down vote up
private static Options getOptions() {
  Options result = new Options();
  OptionGroup group = new OptionGroup();
  Option recordOption = Option.builder(RECORD_OPTION_SHORT)
      .desc("Send repeatable pseudo-random queries directly to Quandl and record the reponses and resulting objects in files")
      .longOpt(RECORD_OPTION_LONG)
      .build();
  Option fileBasedTests = Option.builder(FILE_TESTS_OPTION_SHORT)
      .desc("Run repeatable pseudo-random queries against previously gathered reponses and "
                       + "regression test against previously gathered result objects")
      .longOpt(FILE_TESTS_OPTION_LONG)
      .build();
  Option directTests = Option.builder(DIRECT_TESTS_OPTION_SHORT)
      .desc("Send repeatable pseudo-random queries directly to Quandl and regression test against previously gathered result objects")
      .longOpt(DIRECT_TESTS_OPTION_LONG)
      .build();
  group.addOption(recordOption);
  group.addOption(fileBasedTests);
  group.addOption(directTests);
  result.addOptionGroup(group);
  Option apiKeyOption = Option.builder(API_KEY_OPTION_SHORT)
      .desc("Specify an API key to use when making requests")
      .hasArg(true)
      .argName("The Quandl API Key")
      .required(false)
      .longOpt(API_KEY_OPTION_LONG)
      .build();
  Option requestsOption = Option.builder(REQUESTS_OPTION_SHORT)
      .desc("Number of requests to fuzz (default 200)")
      .hasArg(true)
      .argName("The number of requests")
      .required(false)
      .longOpt(REQUESTS_OPTION_LONG)
      .build();
  Option randomSeedOption = Option.builder(SEED_OPTION_SHORT)
      .desc("Override random seed")
      .hasArg(true)
      .argName("The new seed as a long in decimal")
      .required(false)
      .longOpt(SEED_OPTION_LONG)
      .build();
  result.addOption(apiKeyOption);
  result.addOption(requestsOption);
  result.addOption(randomSeedOption);
  return result;
}
 
Example 17
Source File: DummyProcess.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
synchronized private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
          .create();

  Option clusterOption =
      OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
  clusterOption.setArgs(1);
  clusterOption.setRequired(true);
  clusterOption.setArgName("Cluster name (Required)");

  Option hostOption =
      OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create();
  hostOption.setArgs(1);
  hostOption.setRequired(true);
  hostOption.setArgName("Host name (Required)");

  Option portOption =
      OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create();
  portOption.setArgs(1);
  portOption.setRequired(true);
  portOption.setArgName("Host port (Required)");

  Option cmTypeOption =
      OptionBuilder
          .withLongOpt(helixManagerType)
          .withDescription(
              "Provide cluster manager type (e.g. 'zk', 'static-file', or 'dynamic-file'")
          .create();
  cmTypeOption.setArgs(1);
  cmTypeOption.setRequired(true);
  cmTypeOption
      .setArgName("Clsuter manager type (e.g. 'zk', 'static-file', or 'dynamic-file') (Required)");

  Option zkServerOption =
      OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create();
  zkServerOption.setArgs(1);
  zkServerOption.setRequired(true);
  zkServerOption.setArgName("ZookeeperServerAddress(Required for zk-based cluster manager)");

  // Option rootNsOption = OptionBuilder.withLongOpt(rootNamespace)
  // .withDescription("Provide root namespace for dynamic-file based cluster manager").create();
  // rootNsOption.setArgs(1);
  // rootNsOption.setRequired(true);
  // rootNsOption.setArgName("Root namespace (Required for dynamic-file based cluster manager)");

  Option transDelayOption =
      OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay").create();
  transDelayOption.setArgs(1);
  transDelayOption.setRequired(false);
  transDelayOption.setArgName("Delay time in state transition, in MS");

  OptionGroup optionGroup = new OptionGroup();
  optionGroup.addOption(zkServerOption);

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(clusterOption);
  options.addOption(hostOption);
  options.addOption(portOption);
  options.addOption(transDelayOption);
  options.addOption(cmTypeOption);

  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 18
Source File: ExampleParticipant.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
          .create();

  Option zkServerOption =
      OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create();
  zkServerOption.setArgs(1);
  zkServerOption.setRequired(true);
  zkServerOption.setArgName("ZookeeperServerAddress(Required)");

  Option clusterOption =
      OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
  clusterOption.setArgs(1);
  clusterOption.setRequired(true);
  clusterOption.setArgName("Cluster name (Required)");

  Option instancesOption =
      OptionBuilder.withLongOpt(instances).withDescription("Provide instance names, separated by ':").create();
  instancesOption.setArgs(1);
  instancesOption.setRequired(true);
  instancesOption.setArgName("Instance names (Required)");

  Option transDelayOption =
      OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay").create();
  transDelayOption.setArgs(1);
  transDelayOption.setRequired(false);
  transDelayOption.setArgName("Delay time in state transition, in MS");

  OptionGroup optionGroup = new OptionGroup();
  optionGroup.addOption(zkServerOption);

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(clusterOption);
  options.addOption(instancesOption);
  options.addOption(transDelayOption);

  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 19
Source File: LinkageCheckerArguments.java    From cloud-opensource-java with Apache License 2.0 4 votes vote down vote up
private static Options configureOptions() {
  Options options = new Options();

  OptionGroup inputGroup = new OptionGroup();

  Option bomOption =
      Option.builder("b")
          .longOpt("bom")
          .hasArg()
          .desc("Maven coordinates for a BOM")
          .build();
  inputGroup.addOption(bomOption);

  Option artifactOption =
      Option.builder("a")
          .longOpt("artifacts")
          .hasArgs()
          .valueSeparator(',')
          .desc(
              "Maven coordinates for artifacts (separated by ',')")
          .build();
  inputGroup.addOption(artifactOption);

  Option jarOption =
      Option.builder("j")
          .longOpt("jars")
          .hasArgs()
          .valueSeparator(',')
          .desc("Jar files (separated by ',')")
          .build();
  inputGroup.addOption(jarOption);

  Option repositoryOption =
      Option.builder("m")
          .longOpt("maven-repositories")
          .hasArgs()
          .valueSeparator(',')
          .desc(
              "Maven repository URLs to search for dependencies. "
                  + "The repositories are added to a repository list in order before "
                  + "the default Maven Central (http://repo1.maven.org/maven2/).")
          .build();
  options.addOption(repositoryOption);

  Option noMavenCentralOption =
      Option.builder("nm")
          .longOpt("no-maven-central")
          .hasArg(false)
          .desc(
              "Do not search Maven Central in addition to the repositories specified by -m. "
                  + "Useful when Maven Central is inaccessible.")
          .build();
  options.addOption(noMavenCentralOption);

  Option reportOnlyReachable =
      Option.builder("r")
          .longOpt("report-only-reachable")
          .hasArg(false)
          .desc(
              "Report only reachable linkage errors from the classes in the specified BOM or "
                  + "Maven artifacts")
          .build();
  options.addOption(reportOnlyReachable);

  Option help =
      Option.builder("h")
          .longOpt("help")
          .hasArg(false)
          .desc("Show usage instructions")
          .build();
  options.addOption(help);

  Option exclusionFile =
      Option.builder("e")
          .longOpt("exclusion-file")
          .hasArg(true)
          .desc("Exclusion file to filter out linkage errors based on conditions")
          .build();
  options.addOption(exclusionFile);

  Option writeAsExclusionFile =
      Option.builder("o")
          .longOpt("output-exclusion-file")
          .hasArg(true)
          .desc("Output linkage errors as exclusion rules into the specified file")
          .build();
  options.addOption(writeAsExclusionFile);

  options.addOptionGroup(inputGroup);
  return options;
}
 
Example 20
Source File: GridRandomCommandLineLoader.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}