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

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

源代码1 项目: spork   文件: PigStorage.java
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;
}
 
源代码2 项目: geoportal-server-harvester   文件: Application.java
private Options createOptions() {
  Option help    = new Option("h", "help", false, "print this message");
  Option ver = new Option("v", "version", false, "print the version information and exit");
  Option verbose = new Option("V", "verbose", false, "be extra verbose");
  Option file = new Option("f", "file", true, "executes task defined in the file");
  Option task = new Option("t", "task", true, "executes task defined as JSON");
  Option geo = new Option("g", "geometry", true, "url to accessible geometry service");
  geo.setArgName("url");
  
  Options options = new Options();
  options.addOption(help);
  options.addOption(ver);
  options.addOption(verbose);
  options.addOption(file);
  options.addOption(task);
  options.addOption(geo);
  
  return options;
}
 
源代码3 项目: scheduling   文件: RMStarter.java
private static void initOptions() {
    Option help = new Option("h", "help", false, "to display this help");
    help.setArgName("help");
    help.setRequired(false);
    options.addOption(help);

    Option noDeploy = new Option("ln",
                                 "localNodes",
                                 false,
                                 "start the resource manager deploying default 4 local nodes");
    noDeploy.setArgName("localNodes");
    noDeploy.setRequired(false);
    options.addOption(noDeploy);

    Option nodeTimeout = new Option("t",
                                    "timeout",
                                    true,
                                    "Timeout used to start the nodes (only useful with local nodes, default: " +
                                          DEFAULT_NODE_TIMEOUT + "ms)");
    nodeTimeout.setArgName("timeout");
    nodeTimeout.setRequired(false);
    options.addOption(nodeTimeout);
}
 
源代码4 项目: zserio   文件: JavaExtension.java
@Override
public void registerOptions(org.apache.commons.cli.Options options)
{
    Option option = new Option(OptionJava, true, "generate Java sources");
    option.setArgName("outputDir");
    option.setRequired(false);
    options.addOption(option);
}
 
源代码5 项目: helix   文件: RestAdminApplication.java
@SuppressWarnings("static-access")
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 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);

  return options;
}
 
源代码6 项目: metron   文件: CommonOptions.java
@Nullable
@Override
public Option apply(@Nullable String s) {
  Option o = new Option(s, "log4j", true, "The log4j properties file to load");
  o.setArgName("FILE");
  o.setRequired(false);
  return o;
}
 
源代码7 项目: metron   文件: CommonOptions.java
@Nullable
@Override
public Option apply(@Nullable String input) {
  Option o = new Option(getShortCode(), "import_mode", true
                       , "The Import mode to use: " + Joiner.on(",").join(importModes)
                       + ".  Default: " +defaultMode
                       );
  o.setArgName("MODE");
  o.setRequired(false);
  return o;
}
 
/**
 * Create the options available for the DistributedTestDriver
 * 
 * @return Apache's CLI Options object
 */
private Options createOptions()
{
  Options options = new Options();

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

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

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

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

  return options;
}
 
源代码9 项目: kieker   文件: KaxViz.java
@Override
protected void addAdditionalOptions(final Options options) {
	final Option inputOption = new Option("i", "input", true, "the analysis project file (.kax) loaded");
	final Option outputoption = new Option("svg", true, "name of svg saved on close");

	inputOption.setArgName("filename");
	outputoption.setArgName("filename");

	options.addOption(inputOption);
	options.addOption(outputoption);
}
 
源代码10 项目: metron   文件: CommonOptions.java
@Nullable
@Override
public Option apply(@Nullable String s) {
  Option o = new Option(s, "batchSize", true, "The batch size to use for HBase puts");
  o.setArgName("SIZE");
  o.setRequired(false);
  return o;
}
 
源代码11 项目: kieker   文件: KaxRun.java
@Override
protected void addAdditionalOptions(final Options options) {
	final Option inputOption = new Option("i", "input", true, "the analysis project file (.kax) loaded");
	inputOption.setArgName("filename");

	options.addOption(inputOption);
}
 
源代码12 项目: datawave   文件: UpgradeCounterValues.java
private void generateCommandLineOptions() {
    options = new Options();
    
    tableNameOpt = new Option("tn", "tableName", true, "The name of the table to scan");
    tableNameOpt.setRequired(true);
    options.addOption(tableNameOpt);
    
    instanceNameOpt = new Option("i", "instance", true, "Accumulo instance name");
    instanceNameOpt.setArgName("name");
    instanceNameOpt.setRequired(true);
    options.addOption(instanceNameOpt);
    
    zookeeperOpt = new Option("zk", "zookeeper", true, "Comma-separated list of ZooKeeper servers");
    zookeeperOpt.setArgName("server[,server]");
    zookeeperOpt.setRequired(true);
    options.addOption(zookeeperOpt);
    
    usernameOpt = new Option("u", "username", true, "Accumulo username");
    usernameOpt.setArgName("name");
    usernameOpt.setRequired(true);
    options.addOption(usernameOpt);
    
    passwordOpt = new Option("p", "password", true, "Accumulo password");
    passwordOpt.setArgName("passwd");
    passwordOpt.setRequired(true);
    options.addOption(passwordOpt);
    
    rangesOpt = new Option("r", "range", true, "Range in startRow,endRow format (both start and end are exclusive");
    rangesOpt.setArgName("range");
    rangesOpt.setRequired(false);
    options.addOption(rangesOpt);
    
    bsThreadsOpt = new Option("st", "bwThreads", true, "Number of batch writer threads");
    bsThreadsOpt.setArgName("bwThreads");
    bsThreadsOpt.setRequired(false);
    options.addOption(bsThreadsOpt);
    
    bwThreadsOpt = new Option("wt", "bwThreads", true, "Number of batch writer threads");
    bwThreadsOpt.setArgName("bwThreads");
    bwThreadsOpt.setRequired(false);
    options.addOption(bwThreadsOpt);
    
    bwMemoryOpt = new Option("wm", "bwMemory", true, "Bytes to keep before flushing the batch writer");
    bwMemoryOpt.setArgName("bwMemory");
    bwMemoryOpt.setRequired(false);
    options.addOption(bwMemoryOpt);
}
 
源代码13 项目: datawave   文件: QueryMetricsReporter.java
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;
}
 
源代码14 项目: helix   文件: ClusterStateVerifier.java
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
  Option helpOption =
      OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
          .create();

  Option zkServerOption =
      OptionBuilder.withLongOpt(zkServerAddress).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 timeoutOption =
      OptionBuilder.withLongOpt(timeout).withDescription("Timeout value for verification")
          .create();
  timeoutOption.setArgs(1);
  timeoutOption.setArgName("Timeout value (Optional), default=30s");

  Option sleepIntervalOption =
      OptionBuilder.withLongOpt(period).withDescription("Polling period for verification")
          .create();
  sleepIntervalOption.setArgs(1);
  sleepIntervalOption.setArgName("Polling period value (Optional), default=1s");

  Option resourcesOption =
      OptionBuilder.withLongOpt(resources).withDescription("Specific set of resources to verify")
          .create();
  resourcesOption.setArgs(1);
  resourcesOption.setArgName("Comma-separated resource names, default is all resources");

  Options options = new Options();
  options.addOption(helpOption);
  options.addOption(zkServerOption);
  options.addOption(clusterOption);
  options.addOption(timeoutOption);
  options.addOption(sleepIntervalOption);
  options.addOption(resourcesOption);

  return options;
}
 
源代码15 项目: Elasticsearch   文件: CliToolConfig.java
private OptionBuilder(String shortName, String longName) {
    option = new Option(shortName, "");
    option.setLongOpt(longName);
    option.setArgName(longName);
}
 
源代码16 项目: hadoop   文件: NodeCLI.java
@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;
}
 
源代码17 项目: big-c   文件: NodeCLI.java
@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;
}
 
源代码18 项目: cineast   文件: API.java
private static CommandLine handleCommandLine(String[] args) {
  Options options = new Options();

  options.addOption("h", "help", false, "print this message");
  options.addOption("i", "interactive", false,
      "enables the CLI independently of what is specified in the config");
  options.addOption("3d", "test3d", false,
      "tests Cineast's off-screen 3D renderer. If test succeeds, an image should be exported");

  Option configLocation = new Option(null, "config", true,
      "alternative config file, by default 'cineast.json' is used");
  configLocation.setArgName("CONFIG_FILE");
  options.addOption(configLocation);

  Option server = new Option(null, "server", true,
      "config file for extraction server mode");
  server.setArgName("SERVER_FILE");
  options.addOption(server);

  Option extractionJob = new Option(null, "job", true,
      "job file containing settings for handleExtraction");
  extractionJob.setArgName("JOB_FILE");
  options.addOption(extractionJob);

  options.addOption(Option.builder().longOpt("setup")
      .optionalArg(true)
      .numberOfArgs(1)
      .argName("FLAGS")
      .desc("initialize the underlying storage layer with optional <key=value> parameters")
      .build());

  CommandLineParser parser = new DefaultParser();
  CommandLine line;
  try {
    line = parser.parse(options, args);
  } catch (ParseException e) {
    LOGGER.error("Error parsing command line arguments: {}", e.getMessage());
    return null;
  }

  if (line.hasOption("help")) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("cineast", options);
  }

  return line;
}
 
源代码19 项目: helix   文件: DummyProcess.java
@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;
}
 
源代码20 项目: helix   文件: ExampleParticipant.java
@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;
}