Package org.apache.commons.cli

Examples of org.apache.commons.cli.Options


   *
   * @param conf the <code>Configuration</code> to modify.
   * @param args command-line arguments.
   */
  public GenericOptionsParser(Configuration conf, String[] args) {
    this(conf, new Options(), args);
  }
View Full Code Here


  /**
   * Creates configuration options object.
   */
  @SuppressWarnings("static-access")
  private Options makeOptions() {
    Options options = new Options();
    options
        .addOption("nodfs", false, "Don't start a mini DFS cluster")
        .addOption("nomr", false, "Don't start a mini MR cluster")
        .addOption("useloopbackhosts", false, "Set TaskTracker hostnames to 127.0.1.N")
        .addOption("tasktrackers", true,
            "How many tasktrackers to start (default 1)")
View Full Code Here

   * @param args Command-line arguments.
   * @return true on successful parse; false to indicate that the
   * program should exit.
   */
  private boolean parseArguments(String[] args) {
    Options options = makeOptions();
    CommandLine cli;
    try {
      CommandLineParser parser = new GnuParser();
      cli = parser.parse(options, args);
    } catch(ParseException e) {
View Full Code Here

    String port;
    Server server;
    SocketConnector connector;
    CommandLine cmd = null;
    CommandLineParser parser = new PosixParser();
    Options o = new Options();

    BasicConfigurator.configure();

    o.addOption("p", true, "port");
    try {
      cmd = parser.parse(o, args);
    }
    catch (ParseException exp ) {
      System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );
View Full Code Here

    server.stop();
  }
 
  public static void main(String[] args) {
   
    Options options = new Options();
    options.addOption("p", "port", true, "bind port");
    options.addOption("b", "base", true, "base path");
   
    try {
      CommandLine cl = new PosixParser().parse(options, args);
     
      int port = 8080;
View Full Code Here

public class JRubyJobRunner extends Configured implements Tool {

  public int run(String[] args) throws Exception {
    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption(new Option("script", true, "ruby script"));
    options
        .addOption(new Option("dslfile", true, "hadoop ruby DSL script"));

    CommandLine commandLine = parser.parse(options, args);
    JobConf conf = new JobConf(getConf(), JRubyJobRunner.class);
    conf.setJobName("ruby.runner");
View Full Code Here

    System.exit(res);
  }

  @Override
  public int run(String[] args) throws Exception {
    Options opts = new Options();
    String title = null;
    if (args.length > 0 && args[0].equalsIgnoreCase(APPLICATION)) {
      title = APPLICATION;
      opts.addOption(STATUS_CMD, true,
          "Prints the status of the application.");
      opts.addOption(LIST_CMD, false, "List applications. "
          + "Supports optional use of -appTypes to filter applications "
          + "based on application type, "
          + "and -appStates to filter applications based on application state.");
      opts.addOption(KILL_CMD, true, "Kills the application.");
      opts.addOption(MOVE_TO_QUEUE_CMD, true, "Moves the application to a "
          + "different queue.");
      opts.addOption(QUEUE_CMD, true, "Works with the movetoqueue command to"
          + " specify which queue to move an application to.");
      opts.addOption(HELP_CMD, false, "Displays help for all commands.");
      Option appTypeOpt = new Option(APP_TYPE_CMD, true, "Works with -list to "
          + "filter applications based on "
          + "input comma-separated list of application types.");
      appTypeOpt.setValueSeparator(',');
      appTypeOpt.setArgs(Option.UNLIMITED_VALUES);
      appTypeOpt.setArgName("Types");
      opts.addOption(appTypeOpt);
      Option appStateOpt = new Option(APP_STATE_CMD, true, "Works with -list "
          + "to filter applications based on input comma-separated list of "
          + "application states. " + getAllValidApplicationStates());
      appStateOpt.setValueSeparator(',');
      appStateOpt.setArgs(Option.UNLIMITED_VALUES);
      appStateOpt.setArgName("States");
      opts.addOption(appStateOpt);
      opts.getOption(KILL_CMD).setArgName("Application ID");
      opts.getOption(MOVE_TO_QUEUE_CMD).setArgName("Application ID");
      opts.getOption(QUEUE_CMD).setArgName("Queue Name");
      opts.getOption(STATUS_CMD).setArgName("Application ID");
    } else if (args.length > 0 && args[0].equalsIgnoreCase(APPLICATION_ATTEMPT)) {
      title = APPLICATION_ATTEMPT;
      opts.addOption(STATUS_CMD, true,
          "Prints the status of the application attempt.");
      opts.addOption(LIST_CMD, true,
          "List application attempts for aplication.");
      opts.addOption(HELP_CMD, false, "Displays help for all commands.");
      opts.getOption(STATUS_CMD).setArgName("Application Attempt ID");
      opts.getOption(LIST_CMD).setArgName("Application ID");
    } else if (args.length > 0 && args[0].equalsIgnoreCase(CONTAINER)) {
      title = CONTAINER;
      opts.addOption(STATUS_CMD, true,
          "Prints the status of the container.");
      opts.addOption(LIST_CMD, true,
          "List containers for application attempt.");
      opts.addOption(HELP_CMD, false, "Displays help for all commands.");
      opts.getOption(STATUS_CMD).setArgName("Container ID");
      opts.getOption(LIST_CMD).setArgName("Application Attempt ID");
    }

    int exitCode = -1;
    CommandLine cliParser = null;
    try {
View Full Code Here

public class Main implements Constants {

  public static void main(String[] args) throws Exception {
    // process command line

    Options options = new Options();
    options.addOption("p", "port", true, "service port");
    options.addOption("m", "multiuser", false, "enable multiuser mode");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    int port = 8080;
    if (cmd.hasOption("p")) {
      port = Integer.valueOf(cmd.getOptionValue("p"));
View Full Code Here

    public static final String FAIL_NEVER = "fn";

    public CLIManager()
    {
        options = new Options();

        options.addOption( OptionBuilder.withLongOpt( "file" )
                                        .hasArg()
                                        .withDescription( "Force the use of an alternate POM file." )
                                        .create( ALTERNATE_POM_FILE ) );
View Full Code Here

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

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

    return options;
  }
View Full Code Here

TOP

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

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.