Java Code Examples for org.apache.commons.cli.OptionGroup#addOption()

The following examples show how to use org.apache.commons.cli.OptionGroup#addOption() . 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: 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 2
Source File: CubeMetaExtractor.java    From kylin with Apache License 2.0 6 votes vote down vote up
public CubeMetaExtractor() {
    super();
    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.addOption(OPTION_HYBRID);
    realizationOrProject.addOption(OPTION_All_PROJECT);
    realizationOrProject.setRequired(true);

    options.addOptionGroup(realizationOrProject);
    options.addOption(OPTION_INCLUDE_SEGMENTS);
    options.addOption(OPTION_INCLUDE_JOB);
    options.addOption(OPTION_INCLUDE_SEGMENT_DETAILS);
    options.addOption(OPTION_INCLUDE_ONLY_JOB_OUTPUT);
    options.addOption(OPTION_STORAGE_TYPE);
    options.addOption(OPTION_ENGINE_TYPE);

}
 
Example 3
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 4
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 5
Source File: HBaseUsageExtractor.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public HBaseUsageExtractor() {
    super();
    packageType = "hbase";

    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.setRequired(true);

    options.addOptionGroup(realizationOrProject);
    conf = HBaseConfiguration.create();
    hbaseRootDir = conf.get("hbase.rootdir");
    cachedHMasterUrl = getHBaseMasterUrl();
}
 
Example 6
Source File: TaskAdmin.java    From helix with Apache License 2.0 5 votes vote down vote up
/** Constructs option group containing options required by all drivable jobs */
private static OptionGroup constructStartOptionGroup() {
  @SuppressWarnings("static-access")
  Option workflowFileOption =
      OptionBuilder.withLongOpt(WORKFLOW_FILE_OPTION)
          .withDescription("Local file describing workflow").create();
  workflowFileOption.setArgs(1);
  workflowFileOption.setArgName("workflowFile");

  OptionGroup group = new OptionGroup();
  group.addOption(workflowFileOption);
  return group;
}
 
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: WorfCLI.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
public WorfCLI() {
  options.addOption(new Option(KEYSTORE, "keystore", true, "configuration file for generating tokens inside templates"));
  options.addOption(new Option(OUTPUT, "output", true, "output configuration destination file"));
  options.addOption(new Option(TOKEN, "tokens", false, "generate read/write tokens"));
  options.addOption(new Option(TOKEN_TYPE, true, "token types generated r|w|rw (default rw)"));
  options.addOption(new Option("f", "format", false, "output tokens format. (default JSON)"));
  options.addOption(new Option(QUIET, "quiet", false, "Only tokens or error are written on the console"));

  OptionGroup groupProducerUID = new OptionGroup();
  groupProducerUID.addOption(new Option(UUIDGEN_PRODUCER, "producer-uuid-gen", false, "creates a new universally unique identifier for the producer"));
  groupProducerUID.addOption(new Option(P_UUID, "producer-uuid", true, "data producer uuid"));

  OptionGroup groupOwnerUID = new OptionGroup();
  groupOwnerUID.addOption(new Option(UUIDGEN_OWNER, "owner-uuid-gen", false, "creates a new universally unique identifier for the owner"));
  groupOwnerUID.addOption(new Option(O_UUID, "owner-uuid", true, "data owner uuid (producer uuid by default)"));

  options.addOptionGroup(groupProducerUID);
  options.addOptionGroup(groupOwnerUID);

  options.addOption(new Option(APPNAME, "app-name", true, "token application name. Used by token option or @warp:writeToken@ template"));
  options.addOption(new Option(LABELS, "labels", true, "enclosed label list for read/write tokens (following ingress input format : xbeeId=XBee_40670F0D,moteId=53)"));
  options.addOption(new Option(TTL, "ttl", true, "token time to live (ms). Used by token option or @warp:writeToken@ template"));

  options.addOption(HELP, "help", false, "show help.");
  options.addOption(VERBOSE, "verbose", false, "Verbose mode");
  options.addOption(VERSION, "version", false, "Print version number and return");
  options.addOption(INTERACTIVE, "interactive", false, "Interactive mode, all other options are ignored");
}
 
Example 11
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 12
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 13
Source File: GridVmNodesStarter.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 14
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 15
Source File: IntegrationTestUtil.java    From helix with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options information")
          .create();

  Option zkSvrOption =
      OptionBuilder.hasArgs(1).isRequired(true).withArgName("zookeeperAddress")
          .withLongOpt(zkSvr).withDescription("Provide zookeeper-address").create();

  Option timeoutOption =
      OptionBuilder.hasArgs(1).isRequired(true).withArgName("timeout")
          .withLongOpt(timeout).withDescription("Provide timeout (in ms)").create();

  Option verifyExternalViewOption =
      OptionBuilder.hasArgs().isRequired(false).withArgName("clusterName node1 node2..")
          .withLongOpt(verifyExternalView).withDescription("Verify external-view").create();

  Option verifyClusterStateOption =
      OptionBuilder.hasArgs().isRequired(false).withArgName("clusterName")
          .withLongOpt(verifyClusterState).withDescription("Verify Bestpossible ClusterState").create();

  Option verifyLiveNodesOption =
      OptionBuilder.hasArg().isRequired(false).withArgName("clusterName node1, node2..")
          .withLongOpt(verifyLiveNodes).withDescription("Verify live-nodes").create();

  Option readZNodeOption =
      OptionBuilder.hasArgs(1).isRequired(false).withArgName("zkPath").withLongOpt(readZNode)
          .withDescription("Read znode").create();

  Option readLeaderOption =
      OptionBuilder.hasArgs(1).isRequired(false).withArgName("clusterName")
          .withLongOpt(readLeader).withDescription("Read cluster controller").create();

  OptionGroup optGroup = new OptionGroup();
  optGroup.setRequired(true);
  optGroup.addOption(verifyExternalViewOption);
  optGroup.addOption(verifyClusterStateOption);
  optGroup.addOption(verifyLiveNodesOption);
  optGroup.addOption(readZNodeOption);
  optGroup.addOption(readLeaderOption);

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(zkSvrOption);
  options.addOption(timeoutOption);
  options.addOptionGroup(optGroup);

  return options;
}
 
Example 16
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 17
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 18
Source File: CurrentStateCleanUp.java    From helix with Apache License 2.0 4 votes vote down vote up
private static Options parseCommandLineOptions() {
  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 instanceOption = OptionBuilder.withLongOpt(instance)
      .withDescription("Provide instance name").create();
  instanceOption.setArgs(1);
  instanceOption.setRequired(true);
  instanceOption.setArgName("Instance name");

  Option sessionOption = OptionBuilder.withLongOpt(session)
      .withDescription("Provide instance session").create();
  sessionOption.setArgs(1);
  sessionOption.setRequired(true);
  sessionOption.setArgName("Session name");

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

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(clusterOption);
  options.addOption(instanceOption);
  options.addOption(sessionOption);

  options.addOptionGroup(optionGroup);

  return options;
}
 
Example 19
Source File: SolrIndexer.java    From oodt with Apache License 2.0 4 votes vote down vote up
/**
 * This method builds the command-line options.
 * 
 * @return Returns the supported Options.
 */
@SuppressWarnings("static-access")
public static Options buildCommandLine() {
	Options options = new Options();

	options.addOption(new Option("h", "help", false, "Print this message"));
	options.addOption(new Option("o", "optimize", false,
	    "Optimize the Solr index"));
	options.addOption(new Option("d", "delete", false,
	    "Delete item before indexing"));
	options.addOption(OptionBuilder.withArgName("Solr URL").hasArg()
	    .withDescription("URL to the Solr instance").withLongOpt("solrUrl")
	    .create("su"));
	options.addOption(OptionBuilder.withArgName("Filemgr URL").hasArg()
	    .withDescription("URL to the File Manager").withLongOpt("fmUrl")
	    .create("fmu"));

	OptionGroup group = new OptionGroup();
	Option all = new Option("a", "all", false,
	    "Index all products from the File Manager");
	Option product = OptionBuilder.withArgName("productId").hasArg()
	    .withDescription("Index the product from the File Manager")
	    .withLongOpt("product").create("p");
	Option met = OptionBuilder.withArgName("file").hasArg().withDescription(
	    "Index the product from a metadata file").withLongOpt("metFile")
	    .create("mf");
	Option read = new Option("r", "read", false,
	    "Index all products based on a list of product identifiers passed in");
	Option types = new Option("t", "types", false,
	    "Index all product types from the File Manager");
	Option deleteAll = new Option("da", "deleteAll", false,
	    "Delete all products/types from the Solr index");

	group.addOption(all);
	group.addOption(product);
	group.addOption(met);
	group.addOption(read);
	group.addOption(types);
	group.addOption(deleteAll);
	options.addOptionGroup(group);

	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;
}