Package org.apache.commons.cli

Examples of org.apache.commons.cli.CommandLineParser


  private static final Integer BEAKER_SERVER_PORT_OFFSET = 2;

  private static CommandLine parseCommandLine(String[] args)
    throws ParseException
  {
    CommandLineParser parser = new GnuParser();
    Options opts = new Options();
    opts.addOption("h", "help", false, "print this message");
    opts.addOption(null, "disable-kerberos", false, "do not require kerberos authentication");
    opts.addOption(null, "open-browser", true, "open a web browser connected to the Beaker server");
    opts.addOption(null, "port-base", true, "main port number to use, other ports are allocated starting here");
    opts.addOption(null, "default-notebook", true, "file name to find default notebook");
    opts.addOption(null, "plugin-option", true, "pass option on to plugin");
    opts.addOption(null, "public-server", false, "allow connections from external computers");
    opts.addOption(null, "no-password", false, "do not require a password from external connections " +
                   "(warning: for advanced users only!)");
    CommandLine line = parser.parse(opts, args);
    if (line.hasOption("help")) {
      new HelpFormatter().printHelp("beaker.command", opts);
      System.exit(0);
    }
    return line;
View Full Code Here


        options.addOption("t", "theme", true, "the theme to compile");
        options.addOption("f", "theme-folder", true,
                "the folder containing the theme");
        options.addOption("v", "version", true,
                "the Vaadin version to compile for");
        CommandLineParser parser = new PosixParser();
        CommandLine params = parser.parse(options, args);
        if (!params.hasOption("theme") || !params.hasOption("theme-folder")
                || !params.hasOption("version")) {
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(CompileTheme.class.getName(), options);
View Full Code Here

  public static void main(String args[]) {

    try {
      System.out.println(args[0]);

      CommandLineParser parser = new PosixParser();
      CommandLine line = parser.parse(options, args);

      if (line.hasOption("cassandrahostip")) {
        CountandraUtils.setCassandraHostIp(line
            .getOptionValue("cassandrahostip"));
        if (line.hasOption("consistencylevel")) {
View Full Code Here

    if(args.length == 0) {
      printUsage();
      return;
    }
   
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;

    try {
      cmd = parser.parse(options, args);
    } catch (ParseException e) {
      System.out.println("Error parsing command-line options: ");
      printUsage();
      return;
    }
View Full Code Here

        .create());
    options.addOption(OptionBuilder
        .withLongOpt(OPT_NUM_APPENDS).hasArg()
        .withDescription("number of appends per thread")
        .create());
    CommandLineParser parser = new GnuParser();
    CommandLine line;
    try {
      line = parser.parse( options, args );
      if (line.getArgs().length != 0) {
        throw new ParseException("Unexpected options");
      }
    } catch (ParseException pe) {
      HelpFormatter formatter = new HelpFormatter();
View Full Code Here

   * @return Command-specific arguments
   */
  private String[] parseGeneralOptions(Options opts, Configuration conf,
      String[] args) {
    opts = buildGeneralOptions(opts);
    CommandLineParser parser = new GnuParser();
    try {
      commandLine = parser.parse(opts, args, true);
      processGeneralOptions(conf, commandLine);
      return commandLine.getArgs();
    } catch(ParseException e) {
      LOG.warn("options parsing failed: "+e.getMessage());

View Full Code Here

   */
  private boolean parseArguments(String[] args) {
    Options options = makeOptions();
    CommandLine cli;
    try {
      CommandLineParser parser = new GnuParser();
      cli = parser.parse(options, args);
    } catch(ParseException e) {
      LOG.warn("options parsing failed:  "+e.getMessage());
      new HelpFormatter().printHelp("...", options);
      return false;
    }
View Full Code Here

  static final public void main(String args[]) {
    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() );
      System.exit(-1);
    }
View Full Code Here

            System.exit(1);
        }
    }

    private static boolean start(String[] args) throws Exception {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(OPTIONS, args);
        String output = cmd.getOptionValue(OPT_OUTPUT.getOpt());
        String className = cmd.getOptionValue(OPT_CLASS.getOpt());
        String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt());
        String hadoopWork = cmd.getOptionValue(OPT_HADOOPWORK.getOpt());
        String compilerWork = cmd.getOptionValue(OPT_COMPILERWORK.getOpt());
View Full Code Here

    static Configuration parseConfiguration(String[] args) throws ParseException {
        assert args != null;
        LOG.debug("Analyzing WindGateAbort bootstrap arguments: {}", Arrays.toString(args));

        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(OPTIONS, args);

        String profile = cmd.getOptionValue(OPT_PROFILE.getOpt());
        LOG.debug("WindGate profile: {}", profile);
        String sessionId = cmd.getOptionValue(OPT_SESSION_ID.getOpt());
        LOG.debug("WindGate sessionId: {}", sessionId);
View Full Code Here

TOP

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

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.