org.apache.commons.cli.OptionGroup Java Examples

The following examples show how to use org.apache.commons.cli.OptionGroup. 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: CubeMetaExtractor.java    From kylin-on-parquet-v2 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 #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: 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 #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: 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 #6
Source File: GfxdHelpFormatter.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Appends the usage clause for an OptionGroup to a StringBuilder. The clause
 * is wrapped in square brackets if the group is not required. The display of
 * the options is handled by appendOption
 * 
 * @param buff
 *          the StringBuilder to append to
 * @param group
 *          the group to append
 * @see #appendOption(StringBuffer,Option,boolean)
 */
protected void appendOptionGroup(final StringBuilder buff,
    final OptionGroup group) {
  if (!group.isRequired()) {
    buff.append('[');
  }

  ArrayList<Object> optList = new ArrayList<Object>(group.getOptions());
  Collections.sort(optList, getOptionComparator());
  // for each option in the OptionGroup
  for (Iterator<?> i = optList.iterator(); i.hasNext();) {
    // whether the option is required or not is handled at group level
    appendOption(buff, (Option)i.next(), true);

    if (i.hasNext()) {
      buff.append(" | ");
    }
  }

  if (!group.isRequired()) {
    buff.append(']');
  }
}
 
Example #7
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 #8
Source File: GfxdHelpFormatter.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Appends the usage clause for an OptionGroup to a StringBuilder. The clause
 * is wrapped in square brackets if the group is not required. The display of
 * the options is handled by appendOption
 * 
 * @param buff
 *          the StringBuilder to append to
 * @param group
 *          the group to append
 * @see #appendOption(StringBuffer,Option,boolean)
 */
protected void appendOptionGroup(final StringBuilder buff,
    final OptionGroup group) {
  if (!group.isRequired()) {
    buff.append('[');
  }

  ArrayList<Object> optList = new ArrayList<Object>(group.getOptions());
  Collections.sort(optList, getOptionComparator());
  // for each option in the OptionGroup
  for (Iterator<?> i = optList.iterator(); i.hasNext();) {
    // whether the option is required or not is handled at group level
    appendOption(buff, (Option)i.next(), true);

    if (i.hasNext()) {
      buff.append(" | ");
    }
  }

  if (!group.isRequired()) {
    buff.append(']');
  }
}
 
Example #9
Source File: ZooKeeperMigratorMain.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static Options createOptions() {
    final Options options = new Options();
    options.addOption(OPTION_ZK_MIGRATOR_HELP);
    options.addOption(OPTION_ZK_ENDPOINT);
    options.addOption(OPTION_ZK_AUTH_INFO);
    options.addOption(OPTION_FILE);
    options.addOption(OPTION_IGNORE_SOURCE);
    options.addOption(OPTION_USE_EXISTING_ACL);
    final OptionGroup optionGroupAuth = new OptionGroup().addOption(OPTION_ZK_AUTH_INFO).addOption(OPTION_ZK_KRB_CONF_FILE);
    optionGroupAuth.setRequired(false);
    options.addOptionGroup(optionGroupAuth);
    final OptionGroup optionGroupReadWrite = new OptionGroup().addOption(OPTION_RECEIVE).addOption(OPTION_SEND);
    optionGroupReadWrite.setRequired(true);
    options.addOptionGroup(optionGroupReadWrite);

    return options;
}
 
Example #10
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 #11
Source File: ZooKeeperMigratorMain.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private static Options createOptions() {
    final Options options = new Options();
    options.addOption(OPTION_ZK_MIGRATOR_HELP);
    options.addOption(OPTION_ZK_ENDPOINT);
    options.addOption(OPTION_ZK_AUTH_INFO);
    options.addOption(OPTION_FILE);
    options.addOption(OPTION_IGNORE_SOURCE);
    final OptionGroup optionGroupAuth = new OptionGroup().addOption(OPTION_ZK_AUTH_INFO).addOption(OPTION_ZK_KRB_CONF_FILE);
    optionGroupAuth.setRequired(false);
    options.addOptionGroup(optionGroupAuth);
    final OptionGroup optionGroupReadWrite = new OptionGroup().addOption(OPTION_RECEIVE).addOption(OPTION_SEND);
    optionGroupReadWrite.setRequired(true);
    options.addOptionGroup(optionGroupReadWrite);

    return options;
}
 
Example #12
Source File: HBaseUsageExtractor.java    From kylin 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 #13
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 #14
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 #15
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 #16
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 #17
Source File: OmHelpFormatter.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static List<OmOption> getReqOptions(Options opts) {
	//suppose we have only 1 group (for now)
	OptionGroup g = ((List<OptionGroup>)opts.getRequiredOptions()).get(0);
	List<OmOption> result = new ArrayList<>();
	for (Option o : g.getOptions()) {
		result.add((OmOption)o);
	}
	Collections.sort(result, (o1, o2) -> o1.getOrder() - o2.getOrder());
	return result;
}
 
Example #18
Source File: BitcoinRpcCliOptions.java    From consensusj with Apache License 2.0 5 votes vote down vote up
public BitcoinRpcCliOptions() {
        super();
        this.addOption("?", null, false, "This help message")
// 'conf' and 'datadir' aren't implemented yet.
//            .addOption("c", "conf", true, "Specify configuration file (default: bitcoin.conf)")
//            .addOption("d", "datadir", true, "Specify data directory")
            .addOptionGroup(new OptionGroup()
                    .addOption(new Option(null, "testnet", false, "Use the test network"))
                    .addOption(new Option(null, "regtest", false, "Enter regression test mode")))
            .addOption(Option.builder().longOpt("rpcconnect")
                    .desc("Send commands to node running on <ip> (default: 127.0.0.1)")
                    .hasArg()
                    .argName("ip")
                    .build())
                .addOption(Option.builder().longOpt("rpcport")
                        .desc("Connect to JSON-RPC on <port> (default: 8332 or testnet: 18332)")
                        .hasArg()
                        .argName("port")
                        .build())
                .addOption(null, "rpcwait", false, "Wait for RPC server to start")
                .addOption(Option.builder().longOpt("rpcuser")
                        .desc("Username for JSON-RPC connections")
                        .hasArg()
                        .argName("user")
                        .build())
                .addOption(Option.builder().longOpt("rpcpassword")
                        .desc("Password for JSON-RPC connections")
                        .hasArg()
                        .argName("pw")
                        .build())
            .addOption(null, "rpcssl", false, "Use https for JSON-RPC connections");
    }
 
Example #19
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 */
@SuppressWarnings("static-access")
private static OptionGroup contructGenericRequiredOptionGroup() {
  Option zkAddressOption =
      OptionBuilder.isRequired().withLongOpt(ZK_ADDRESS)
          .withDescription("ZK address managing cluster").create();
  zkAddressOption.setArgs(1);
  zkAddressOption.setArgName("zkAddress");

  Option clusterNameOption =
      OptionBuilder.isRequired().withLongOpt(CLUSTER_NAME_OPTION).withDescription("Cluster name")
          .create();
  clusterNameOption.setArgs(1);
  clusterNameOption.setArgName("clusterName");

  Option taskResourceOption =
      OptionBuilder.isRequired().withLongOpt(RESOURCE_OPTION)
          .withDescription("Workflow or job name").create();
  taskResourceOption.setArgs(1);
  taskResourceOption.setArgName("resourceName");

  OptionGroup group = new OptionGroup();
  group.addOption(zkAddressOption);
  group.addOption(clusterNameOption);
  group.addOption(taskResourceOption);
  return group;
}
 
Example #20
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 #21
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 #22
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 #23
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 #24
Source File: SentrySchemaTool.java    From incubator-sentry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static void initOptions(Options cmdLineOptions) {
  Option help = new Option("help", "print this message");
  Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade");
  Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg().
              withDescription("Schema upgrade from a version").
              create("upgradeSchemaFrom");
  Option initOpt = new Option("initSchema", "Schema initialization");
  Option initToOpt = OptionBuilder.withArgName("initTo").hasArg().
              withDescription("Schema initialization to a version").
              create("initSchemaTo");
  Option infoOpt = new Option("info", "Show config and schema details");

  OptionGroup optGroup = new OptionGroup();
  optGroup.addOption(upgradeOpt).addOption(initOpt).
              addOption(help).addOption(upgradeFromOpt).
              addOption(initToOpt).addOption(infoOpt);
  optGroup.setRequired(true);

  Option userNameOpt = OptionBuilder.withArgName("user")
              .hasArg()
              .withDescription("Override config file user name")
              .create("userName");
  Option passwdOpt = OptionBuilder.withArgName("password")
              .hasArg()
               .withDescription("Override config file password")
               .create("passWord");
  Option dbTypeOpt = OptionBuilder.withArgName("databaseType")
              .hasArg().withDescription("Metastore database type [" +
              SentrySchemaHelper.DB_DERBY + "," +
              SentrySchemaHelper.DB_MYSQL + "," +
              SentrySchemaHelper.DB_ORACLE + "," +
              SentrySchemaHelper.DB_POSTGRACE + "," +
              SentrySchemaHelper.DB_DB2 + "]")
              .create("dbType");
  Option dbOpts = OptionBuilder.withArgName("databaseOpts")
              .hasArgs().withDescription("Backend DB specific options")
              .create("dbOpts");

  Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)");
  Option verboseOpt = new Option("verbose", "only print SQL statements");

  Option configOpt = OptionBuilder.withArgName("confName").hasArgs()
      .withDescription("Sentry Service configuration file").isRequired(true)
      .create(ServiceConstants.ServiceArgs.CONFIG_FILE_LONG);

  cmdLineOptions.addOption(help);
  cmdLineOptions.addOption(dryRunOpt);
  cmdLineOptions.addOption(userNameOpt);
  cmdLineOptions.addOption(passwdOpt);
  cmdLineOptions.addOption(dbTypeOpt);
  cmdLineOptions.addOption(verboseOpt);
  cmdLineOptions.addOption(dbOpts);
  cmdLineOptions.addOption(configOpt);
  cmdLineOptions.addOptionGroup(optGroup);
}
 
Example #25
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 #26
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 #27
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 #28
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 #29
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 #30
Source File: RegressionTests.java    From quandl4j with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-access")
private static Options getOptions() {
  Options result = new Options();
  OptionGroup group = new OptionGroup();
  Option recordOption = OptionBuilder
      .withDescription("Send repeatable pseudo-random queries directly to Quandl and record the reponses and resulting objects in files")
      .withLongOpt(RECORD_OPTION_LONG)
      .create(RECORD_OPTION_SHORT);
  Option fileBasedTests = OptionBuilder
      .withDescription("Run repeatable pseudo-random queries against previously gathered reponses and "
                       + "regression test against previously gathered result objects")
      .withLongOpt(FILE_TESTS_OPTION_LONG)
      .create(FILE_TESTS_OPTION_SHORT);
  Option directTests = OptionBuilder
      .withDescription("Send repeatable pseudo-random queries directly to Quandl and regression test against previously gathered result objects")
      .withLongOpt(DIRECT_TESTS_OPTION_LONG)
      .create(DIRECT_TESTS_OPTION_SHORT);
  group.addOption(recordOption);
  group.addOption(fileBasedTests);
  group.addOption(directTests);
  result.addOptionGroup(group);
  Option apiKeyOption = OptionBuilder
      .withDescription("Specify an API key to use when making requests")
      .hasArg(true)
      .withArgName("The Quandl API Key")
      .isRequired(false)
      .withLongOpt(API_KEY_OPTION_LONG)
      .create(API_KEY_OPTION_SHORT);
  Option requestsOption = OptionBuilder
      .withDescription("Number of requests to fuzz (default 200)")
      .hasArg(true)
      .withArgName("The number of requests")
      .isRequired(false)
      .withLongOpt(REQUESTS_OPTION_LONG)
      .create(REQUESTS_OPTION_SHORT);
  Option randomSeedOption = OptionBuilder
      .withDescription("Override random seed")
      .hasArg(true)
      .withArgName("The new seed as a long in decimal")
      .isRequired(false)
      .withLongOpt(SEED_OPTION_LONG)
      .create(SEED_OPTION_SHORT);
  result.addOption(apiKeyOption);
  result.addOption(requestsOption);
  result.addOption(randomSeedOption);
  return result;
}