Java Code Examples for org.apache.commons.cli.Option#setArgs()

The following examples show how to use org.apache.commons.cli.Option#setArgs() . 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: CommandLineClient.java    From termsuite-core with Apache License 2.0 6 votes vote down vote up
private Option addDeclaredOption(CliOption option) {
	Preconditions.checkArgument(
			!declaredOptions.contains(option),
			"Option %s already declared.", 
			option);
	declaredOptions.add(option);
	Option opt = new Option(
			option.getOptShortName(), 
			option.getOptName(), 
			option.hasArg(), 
			option.getDescription());
	if(option.getArgType() == OptType.T_TERM_LIST)
		opt.setArgs(Option.UNLIMITED_VALUES);
	options.addOption(opt);
	return opt;
}
 
Example 2
Source File: Main.java    From swift-t with Apache License 2.0 6 votes vote down vote up
private static Options initOptions() {
  Options opts = new Options();

  Option module = new Option(INCLUDE_FLAG, "include", true,
                                  "Add to import search path");
  opts.addOption(module);

  Option arg = new Option(SWIFT_PROG_ARG_FLAG, "arg", true,
      "Compile-time argument");
  arg.setArgs(2);
  arg.setValueSeparator('=');
  opts.addOption(arg);

  Option preprocArg = new Option(PREPROC_MACRO_FLAG, true,
                                  "Preprocessor definition");
  opts.addOption(preprocArg);

  opts.addOption(UPDATE_FLAG, false, "Update output only if out of date");
  return opts;
}
 
Example 3
Source File: Dump.java    From cumulusrdf with Apache License 2.0 6 votes vote down vote up
@Override
Options getOptions() {
	final Option inputO = new Option("o", "name of output file");
	inputO.setArgs(1);
	inputO.setRequired(true);
	
	final Option inputS = new Option("s", "Storage layout (e.g. triple or quad; defaults to triple)");
	inputS.setArgs(1);

	final Option batchF = new Option("f", "all common RDF formats (e.g., 'n-triples', 'n-quads', or 'rdf/xml') (default: 'n-triples')");
	batchF.setArgs(1);

	final Option helpO = new Option("h", "print help");

	final Options options = new Options();
	options.addOption(inputO);
	options.addOption(batchF);
	options.addOption(helpO);
	return options;
}
 
Example 4
Source File: Load.java    From cumulusrdf with Apache License 2.0 6 votes vote down vote up
@Override
Options getOptions() {
	final Option inputO = new Option("i", "Name of file to read");
	inputO.setRequired(true);
	inputO.setArgs(1);

	final Option storageO = new Option("s", "Storage layout to use (triple|quad)");
	storageO.setArgs(1);

	final Option batchO = new Option("b", "Batch size - number of triples (default: 1000)");
	batchO.setArgs(1);

	final Option helpO = new Option("h", "Print help");

	final Options options = new Options();
	options.addOption(inputO);
	options.addOption(storageO);
	options.addOption(batchO);
	options.addOption(helpO);
	
	return options;
}
 
Example 5
Source File: PigStorage.java    From spork with Apache License 2.0 6 votes vote down vote up
private Options populateValidOptions() {
    Options validOptions = new Options();
    validOptions.addOption("schema", false, "Loads / Stores the schema of the relation using a hidden JSON file.");
    validOptions.addOption("noschema", false, "Disable attempting to load data schema from the filesystem.");
    validOptions.addOption(TAG_SOURCE_FILE, false, "Appends input source file name to beginning of each tuple.");
    validOptions.addOption(TAG_SOURCE_PATH, false, "Appends input source file path to beginning of each tuple.");
    validOptions.addOption("tagsource", false, "Appends input source file name to beginning of each tuple.");
    Option overwrite = new Option(" ", "Overwrites the destination.");
    overwrite.setLongOpt("overwrite");
    overwrite.setOptionalArg(true);
    overwrite.setArgs(1);
    overwrite.setArgName("overwrite");
    validOptions.addOption(overwrite);
    
    return validOptions;
}
 
Example 6
Source File: Remove.java    From cumulusrdf with Apache License 2.0 6 votes vote down vote up
@Override
Options getOptions() {
	final Option inputO = new Option("q", "sparql construct query string. all its bindings will be removed.");
	inputO.setArgs(1);
	inputO.setRequired(true);
	
	final Option verboseO = new Option("v", "verbose (default: false)");
	verboseO.setArgs(1);

	final Option storageO = new Option("s", "storage layout to use (triple|quad) (needs to match webapp configuration)");
	storageO.setArgs(1);

	final Option helpO = new Option("h", "print help");

	final Options options = new Options();
	options.addOption(inputO);
	options.addOption(storageO);
	options.addOption(helpO);
	
	return options;
}
 
Example 7
Source File: CliModel.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
CliModel(Set<Field> fields) {
    for (Field field : fields) {
        CliOption optionAnnotation = field.getAnnotation(CliOption.class);
        CliArgs argsAnnotation = field.getAnnotation(CliArgs.class);

        if (optionAnnotation != null) {
            Option option = new Option(
                    optionAnnotation.name(),
                    optionAnnotation.longName(),
                    optionAnnotation.valueCount() > 0 || optionAnnotation.valueCount() == -1,
                    optionAnnotation.description()
            );

            if (optionAnnotation.valueCount() == -1) {
                option.setArgs(Option.UNLIMITED_VALUES);
            } else if (optionAnnotation.valueCount() > 0) {
                option.setArgs(optionAnnotation.valueCount());
            }

            option.setValueSeparator(optionAnnotation.valueSeparator());
            option.setRequired(optionAnnotation.mandatory());
            option.setOptionalArg(!optionAnnotation.mandatoryValue());
            optionAnnotations.add(optionAnnotation);
            optionFields.add(field);
            options.addOption(option);
        } else if (argsAnnotation != null) {
            mandatoryArgsCount = argsAnnotation.mandatoryCount();
            argsField = field;
        }
    }
}
 
Example 8
Source File: VerifyCommand.java    From robot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Initialze the command. */
public VerifyCommand() {
  Options o = CommandLineHelper.getCommonOptions();
  o.addOption("i", "input", true, "Input Ontology");

  Option queries = new Option("q", "queries", true, "verify one or more SPARQL queries");
  queries.setArgs(Option.UNLIMITED_VALUES);
  o.addOption(queries);

  o.addOption("O", "output-dir", true, "Directory to place reports in");

  options = o;
}
 
Example 9
Source File: LoggingTimestampConverterTool.java    From kieker with Apache License 2.0 5 votes vote down vote up
@Override
protected void addAdditionalOptions(final Options options) {
	final Option option = new Option(LoggingTimestampConverterTool.FLAG_TIMESTAMPS_PARAMETER, "timestamps", true,
			"List of timestamps (UTC timezone) to convert");
	option.setArgName("timestamp1 ... timestampN");
	option.setRequired(false);
	option.setArgs(Option.UNLIMITED_VALUES);

	options.addOption(option);
}
 
Example 10
Source File: OptionBuilder.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an Option using OptionBuilder's State and the given parameters.
 *
 * @param opt
 *            short representation of the option
 * @param longOpt
 *            long representation of the option
 * @param desc
 *            descibes the function of the option
 * @return the new Option
 */
public Option create(final String opt, final String longOpt, final String desc) {
    final Option option = new Option(opt, desc);
    option.setLongOpt(longOpt);
    option.setArgs(args);
    option.setRequired(required);
    option.setOptionalArg(optionalArg);
    option.setType(type);
    option.setValueSeparator(valSeparator);
    
    return option;
}
 
Example 11
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 12
Source File: DBToolOptions.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Option registerOptionalOption(String opt, String longOpt, String description, int numArgs) {
	Option option = OptionBuilder.create(opt);
	option.setRequired(false);
	option.setDescription("option: " + description);
	option.setLongOpt(longOpt);
	option.setArgs(numArgs);
	optionalOptionMap.put(opt, option);
	return option;
}
 
Example 13
Source File: HelixRestMain.java    From helix with Apache License 2.0 5 votes vote down vote up
private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(HELP).withDescription("Prints command-line options info")
          .create();
  helpOption.setArgs(0);
  helpOption.setRequired(false);
  helpOption.setArgName("print help message");

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

  Option helixRestNamespaceOption = OptionBuilder.withLongOpt(NAMESPACE_MANIFEST_FILE)
      .withDescription("A yaml file describing helix namespace")
      .create();
  helixRestNamespaceOption.setArgs(1);
  helixRestNamespaceOption.setRequired(false);
  helixRestNamespaceOption.setArgName("NamespaceManifestFile(Optional)");

  Option portOption =
      OptionBuilder.withLongOpt(PORT).withDescription("Provide web service port").create();
  portOption.setArgs(1);
  portOption.setRequired(false);
  portOption.setArgName("web service port, default: " + DEFAULT_PORT);

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(zkServerOption);
  options.addOption(portOption);
  options.addOption(helixRestNamespaceOption);

  return options;
}
 
Example 14
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 15
Source File: NodeCLI.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public int run(String[] args) throws Exception {

  Options opts = new Options();
  opts.addOption(HELP_CMD, false, "Displays help for all commands.");
  opts.addOption(STATUS_CMD, true, "Prints the status report of the node.");
  opts.addOption(LIST_CMD, false, "List all running nodes. " +
      "Supports optional use of -states to filter nodes " +
      "based on node state, all -all to list all nodes.");
  Option nodeStateOpt = new Option(NODE_STATE_CMD, true,
      "Works with -list to filter nodes based on input comma-separated list of node states.");
  nodeStateOpt.setValueSeparator(',');
  nodeStateOpt.setArgs(Option.UNLIMITED_VALUES);
  nodeStateOpt.setArgName("States");
  opts.addOption(nodeStateOpt);
  Option allOpt = new Option(NODE_ALL, false,
      "Works with -list to list all nodes.");
  opts.addOption(allOpt);
  opts.getOption(STATUS_CMD).setArgName("NodeId");

  int exitCode = -1;
  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    sysout.println("Missing argument for options");
    printUsage(opts);
    return exitCode;
  }

  if (cliParser.hasOption("status")) {
    if (args.length != 2) {
      printUsage(opts);
      return exitCode;
    }
    printNodeStatus(cliParser.getOptionValue("status"));
  } else if (cliParser.hasOption("list")) {
    Set<NodeState> nodeStates = new HashSet<NodeState>();
    if (cliParser.hasOption(NODE_ALL)) {
      for (NodeState state : NodeState.values()) {
        nodeStates.add(state);
      }
    } else if (cliParser.hasOption(NODE_STATE_CMD)) {
      String[] types = cliParser.getOptionValues(NODE_STATE_CMD);
      if (types != null) {
        for (String type : types) {
          if (!type.trim().isEmpty()) {
            nodeStates.add(NodeState.valueOf(
                org.apache.hadoop.util.StringUtils.toUpperCase(type.trim())));
          }
        }
      }
    } else {
      nodeStates.add(NodeState.RUNNING);
    }
    listClusterNodes(nodeStates);
  } else if (cliParser.hasOption(HELP_CMD)) {
    printUsage(opts);
    return 0;
  } else {
    syserr.println("Invalid Command Usage : ");
    printUsage(opts);
  }
  return 0;
}
 
Example 16
Source File: NodeCLI.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public int run(String[] args) throws Exception {

  Options opts = new Options();
  opts.addOption(HELP_CMD, false, "Displays help for all commands.");
  opts.addOption(STATUS_CMD, true, "Prints the status report of the node.");
  opts.addOption(LIST_CMD, false, "List all running nodes. " +
      "Supports optional use of -states to filter nodes " +
      "based on node state, all -all to list all nodes.");
  Option nodeStateOpt = new Option(NODE_STATE_CMD, true,
      "Works with -list to filter nodes based on input comma-separated list of node states.");
  nodeStateOpt.setValueSeparator(',');
  nodeStateOpt.setArgs(Option.UNLIMITED_VALUES);
  nodeStateOpt.setArgName("States");
  opts.addOption(nodeStateOpt);
  Option allOpt = new Option(NODE_ALL, false,
      "Works with -list to list all nodes.");
  opts.addOption(allOpt);
  opts.getOption(STATUS_CMD).setArgName("NodeId");

  int exitCode = -1;
  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    sysout.println("Missing argument for options");
    printUsage(opts);
    return exitCode;
  }

  if (cliParser.hasOption("status")) {
    if (args.length != 2) {
      printUsage(opts);
      return exitCode;
    }
    printNodeStatus(cliParser.getOptionValue("status"));
  } else if (cliParser.hasOption("list")) {
    Set<NodeState> nodeStates = new HashSet<NodeState>();
    if (cliParser.hasOption(NODE_ALL)) {
      for (NodeState state : NodeState.values()) {
        nodeStates.add(state);
      }
    } else if (cliParser.hasOption(NODE_STATE_CMD)) {
      String[] types = cliParser.getOptionValues(NODE_STATE_CMD);
      if (types != null) {
        for (String type : types) {
          if (!type.trim().isEmpty()) {
            nodeStates.add(NodeState.valueOf(
                org.apache.hadoop.util.StringUtils.toUpperCase(type.trim())));
          }
        }
      }
    } else {
      nodeStates.add(NodeState.RUNNING);
    }
    listClusterNodes(nodeStates);
  } else if (cliParser.hasOption(HELP_CMD)) {
    printUsage(opts);
    return 0;
  } else {
    syserr.println("Invalid Command Usage : ");
    printUsage(opts);
  }
  return 0;
}
 
Example 17
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 18
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 19
Source File: JmxDumper.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 domainOption =
      OptionBuilder.withLongOpt(domain).withDescription("Domain of the JMX bean").create();

  domainOption.setArgs(1);
  domainOption.setRequired(true);

  Option fieldsOption =
      OptionBuilder.withLongOpt(fields).withDescription("Fields of the JMX bean to sample")
          .create();
  fieldsOption.setArgs(1);
  fieldsOption.setRequired(false);

  Option operationOption =
      OptionBuilder.withLongOpt(operations).withDescription("Operation to invoke").create();
  operationOption.setArgs(1);
  operationOption.setRequired(true);

  Option periodOption =
      OptionBuilder.withLongOpt(period).withDescription("Sampling period in MS").create();
  periodOption.setArgs(1);
  periodOption.setRequired(false);

  Option classOption =
      OptionBuilder.withLongOpt(className).withDescription("Classname of the MBean").create();
  classOption.setArgs(1);
  classOption.setRequired(true);

  Option patternOption =
      OptionBuilder.withLongOpt(pattern).withDescription("pattern of the MBean").create();
  patternOption.setArgs(1);
  patternOption.setRequired(true);

  Option outputFileOption =
      OptionBuilder.withLongOpt(outputFile).withDescription("outputFileName").create();
  outputFileOption.setArgs(1);
  outputFileOption.setRequired(false);

  Option jmxUrlOption =
      OptionBuilder.withLongOpt(jmxUrl).withDescription("jmx port to connect to").create();
  jmxUrlOption.setArgs(1);
  jmxUrlOption.setRequired(true);

  Option sampleCountOption =
      OptionBuilder.withLongOpt(sampleCount).withDescription("# of samples to take").create();
  sampleCountOption.setArgs(1);
  sampleCountOption.setRequired(false);

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(domainOption);
  options.addOption(fieldsOption);
  options.addOption(operationOption);
  options.addOption(classOption);
  options.addOption(outputFileOption);
  options.addOption(jmxUrlOption);
  options.addOption(patternOption);
  options.addOption(periodOption);
  options.addOption(sampleCountOption);
  return options;
}
 
Example 20
Source File: QueryMetricsReporter.java    From datawave with Apache License 2.0 4 votes vote down vote up
private Options getOptions() {
    Options options = new Options();
    
    instanceOpt = new Option("i", "instance", true, "Accumulo instance name");
    instanceOpt.setArgName("name");
    instanceOpt.setRequired(true);
    options.addOption(instanceOpt);
    
    zookeepersOpt = new Option("zk", "zookeeper", true, "Comma-separated list of ZooKeeper servers");
    zookeepersOpt.setArgName("server[,server]");
    zookeepersOpt.setRequired(true);
    options.addOption(zookeepersOpt);
    
    userOpt = new Option("u", "username", true, "Accumulo username");
    userOpt.setArgName("name");
    userOpt.setRequired(true);
    options.addOption(userOpt);
    
    passwordOpt = new Option("p", "password", true, "Accumulo password");
    passwordOpt.setArgName("passwd");
    passwordOpt.setRequired(true);
    options.addOption(passwordOpt);
    
    beginOpt = new Option("b", "begin", true, "Begin date");
    beginOpt.setArgName("date");
    beginOpt.setRequired(true);
    options.addOption(beginOpt);
    
    endOpt = new Option("e", "end", true, "End date");
    endOpt.setArgName("date");
    endOpt.setRequired(true);
    options.addOption(endOpt);
    
    tableOpt = new Option("t", "table", true, "Specify a table output override for testing purposes.");
    tableOpt.setArgName("table");
    tableOpt.setRequired(false);
    options.addOption(tableOpt);
    
    useAllQueryPagesOpt = new Option("a", "allPages", false, "If present, query latency will use all pages in the query.");
    useAllQueryPagesOpt.setRequired(false);
    useAllQueryPagesOpt.setArgs(0);
    options.addOption(useAllQueryPagesOpt);
    
    verboseSummariesOpt = new Option("v", "verbose", false, "Print extra statistics on queries in the date range.");
    verboseSummariesOpt.setRequired(false);
    verboseSummariesOpt.setArgs(0);
    options.addOption(verboseSummariesOpt);
    
    queryUserOpt = new Option("qu", "queryUser", false, "Limit the metrics to a specific user");
    queryUserOpt.setRequired(false);
    queryUserOpt.setArgs(1);
    queryUserOpt.setArgName("queryUser");
    options.addOption(queryUserOpt);
    
    return options;
}