Package org.apache.commons.cli

Examples of org.apache.commons.cli.Option


    protected void addOptionWithParam(String longOption, String shortOption, String argName, String desc) {
        OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(argName);
        optionBuilder = optionBuilder.withLongOpt(longOption);
        optionBuilder = optionBuilder.withDescription(desc);
        Option option = optionBuilder.create(shortOption);
        options.addOption(option);
    }
View Full Code Here


    System.err.println("Usage:");
    System.err.println(String.format("./hbase %s <options>",
        DataBlockEncodingTool.class.getName()));
    System.err.println("Options:");
    for (Object it : options.getOptions()) {
      Option opt = (Option) it;
      if (opt.hasArg()) {
        System.err.println(String.format("-%s %s: %s", opt.getOpt(),
            opt.getArgName(), opt.getDescription()));
      } else {
        System.err.println(String.format("-%s: %s", opt.getOpt(),
            opt.getDescription()));
      }
    }
  }
View Full Code Here

{
    public void testCLI13()
        throws ParseException
    {
        final String debugOpt = "debug";
        Option debug = OptionBuilder
            .withArgName( debugOpt )
            .withDescription( "turn on debugging" )
            .withLongOpt( debugOpt )
            .hasArg()
            .create( 'd' );
View Full Code Here

        assertEquals("-something", commandLine.getOptionValue( 't'));
    }

    private Options buildCommandLineOptions()
    {
        Option opt = OptionBuilder.withArgName( "t").hasArg().create('t');
        Options options = new Options();
        options.addOption( opt);
        return options;
    }
View Full Code Here

   
  /*
   * Specify properties of each generic option
   */
  static private Options buildGeneralOptions() {
    Option fs = OptionBuilder.withArgName("local|namenode:port")
      .hasArg()
      .withDescription("specify a namenode")
      .create("fs");
    Option jt = OptionBuilder.withArgName("local|jobtracker:port")
      .hasArg()
      .withDescription("specify a job tracker")
      .create("jt");
    Option oconf = OptionBuilder.withArgName("configuration file")
      .hasArg()
      .withDescription("specify an application configuration file")
      .create("conf");
    Option property = OptionBuilder.withArgName("property=value")
      .hasArgs()
      .withArgPattern("=", 1)
      .withDescription("use value for given property")
      .create('D');
    Options opts = new Options();
View Full Code Here

  }

  @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 clusterOption = OptionBuilder.withLongOpt(CLUSTERNAME)
        .withDescription("Provide cluster name").create();
    clusterOption.setArgs(1);
    clusterOption.setRequired(true);
    clusterOption.setArgName("Cluster name(Required)");

    Option instanceOption = OptionBuilder.withLongOpt(INSTANCENAME)
        .withDescription("Provide name for this instance").create();
    instanceOption.setArgs(1);
    instanceOption.setRequired(false);
    instanceOption.setArgName("Instance name(Optional, defaults to localhost)");

    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(clusterOption);
View Full Code Here

    public boolean proceed() {
      return proceed;
    }

    private Options buildOptions() {
      Option compress =
          OptionBuilder.withLongOpt("compress").withArgName("[none|lzo|gz|snappy]")
              .hasArg().withDescription("compression scheme").create('c');

      Option fileSize =
          OptionBuilder.withLongOpt("file-size").withArgName("size-in-MB")
              .hasArg().withDescription("target size of the file (in MB).")
              .create('s');

      Option fsInputBufferSz =
          OptionBuilder.withLongOpt("fs-input-buffer").withArgName("size")
              .hasArg().withDescription(
                  "size of the file system input buffer (in bytes).").create(
                  'i');

      Option fsOutputBufferSize =
          OptionBuilder.withLongOpt("fs-output-buffer").withArgName("size")
              .hasArg().withDescription(
                  "size of the file system output buffer (in bytes).").create(
                  'o');

      Option keyLen =
          OptionBuilder
              .withLongOpt("key-length")
              .withArgName("min,max")
              .hasArg()
              .withDescription(
                  "the length range of the key (in bytes)")
              .create('k');

      Option valueLen =
          OptionBuilder
              .withLongOpt("value-length")
              .withArgName("min,max")
              .hasArg()
              .withDescription(
                  "the length range of the value (in bytes)")
              .create('v');

      Option blockSz =
          OptionBuilder.withLongOpt("block").withArgName("size-in-KB").hasArg()
              .withDescription("minimum block size (in KB)").create('b');

      Option operation =
          OptionBuilder.withLongOpt("operation").withArgName("r|w|rw").hasArg()
              .withDescription(
                  "action: seek-only, create-only, seek-after-create").create(
                  'x');

      Option rootDir =
          OptionBuilder.withLongOpt("root-dir").withArgName("path").hasArg()
              .withDescription(
                  "specify root directory where files will be created.")
              .create('r');

      Option file =
          OptionBuilder.withLongOpt("file").withArgName("name").hasArg()
              .withDescription("specify the file name to be created or read.")
              .create('f');

      Option seekCount =
          OptionBuilder
              .withLongOpt("seek")
              .withArgName("count")
              .hasArg()
              .withDescription(
                  "specify how many seek operations we perform (requires -x r or -x rw.")
              .create('n');
     
      Option trialCount =
          OptionBuilder
              .withLongOpt("trials")
              .withArgName("n")
              .hasArg()
              .withDescription(
                  "specify how many times to run the whole benchmark")
              .create('t');

      Option useRawFs =
          OptionBuilder
            .withLongOpt("rawfs")
            .withDescription("use raw instead of checksummed file system")
            .create();
     
      Option help =
          OptionBuilder.withLongOpt("help").hasArg(false).withDescription(
              "show this screen").create("h");

      return new Options().addOption(compress).addOption(fileSize).addOption(
          fsInputBufferSz).addOption(fsOutputBufferSize).addOption(keyLen)
View Full Code Here

        return httpexecutor;
    }
   
    public static void main(String[] args) throws Exception {

        Option iopt = new Option("i", false, "Do HEAD requests instead of GET.");
        iopt.setRequired(false);
       
        Option kopt = new Option("k", false, "Enable the HTTP KeepAlive feature, " +
                "i.e., perform multiple requests within one HTTP session. " +
                "Default is no KeepAlive");
        kopt.setRequired(false);
       
        Option nopt = new Option("n", true, "Number of requests to perform for the " +
                "benchmarking session. The default is to just perform a single " +
                "request which usually leads to non-representative benchmarking " +
                "results.");
        nopt.setRequired(false);
        nopt.setArgName("requests");
       
        Option popt = new Option("p", true, "File containing data to POST.");
        popt.setRequired(false);
        popt.setArgName("POST-file");

        Option Topt = new Option("T", true, "Content-type header to use for POST data.");
        Topt.setRequired(false);
        Topt.setArgName("content-type");

        Option vopt = new Option("v", true, "Set verbosity level - 4 and above prints " +
                "information on headers, 3 and above prints response codes (404, 200, " +
                "etc.), 2 and above prints warnings and info.");
        vopt.setRequired(false);
        vopt.setArgName("verbosity");

        Option hopt = new Option("h", false, "Display usage information.");
        nopt.setRequired(false);
       
        Options options = new Options();
        options.addOption(iopt);
        options.addOption(kopt);
View Full Code Here

                + "var/config/config.xml such that only the modules listed on "
                + "the command line will be started.  Note that many J2EE "
                + "features depend on certain modules being started, so you "
                + "should be very careful what you omit.  Any arguments after "
                + "this are assumed to be module names.");
        Option option = optionBuilder.create(ARGUMENT_MODULE_OVERRIDE_SHORTFORM);
        options.addOption(option);
    }
View Full Code Here

    }

    protected void addProgressOptions() {
        OptionGroup optionGroup = new OptionGroup();

        Option option = new Option(ARGUMENT_NO_PROGRESS_SHORTFORM,
                ARGUMENT_NO_PROGRESS,
                false,
                "Suppress the normal startup progress bar. This is typically "
                        + "used when redirecting console output to a file, or starting "
                        + "the server from an IDE or other tool.");
        optionGroup.addOption(option);

        option = new Option(ARGUMENT_LONG_PROGRESS_SHORTFORM,
                ARGUMENT_LONG_PROGRESS,
                false,
                "Write startup progress to the console in a format that is "
                        + "suitable for redirecting console output to a file, or starting "
                        + "the server from an IDE or other tool (doesn't use linefeeds to "
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.