Package org.apache.commons.cli

Examples of org.apache.commons.cli.GnuParser


    return options;
  }

  protected static String[] processLocalArgs(String[] cliArgs) throws IOException, ParseException
  {
    CommandLineParser cliParser = new GnuParser();
    Options cliOptions = constructCommandLineOptions();

    CommandLine cmd = cliParser.parse(cliOptions, cliArgs, true);
    // Options here has to be up front
    if (cmd.hasOption(RELAY_HOST_OPT_NAME))
    {
      _relayHost = cmd.getOptionValue(RELAY_HOST_OPT_NAME);
      LOG.info("Relay Host = " + _relayHost);
View Full Code Here


   *                                 writeLastTS TIMESTAMP       
   */
  public static void main(String[] args) {
    try
    {
      GnuParser cmdLineParser  = new GnuParser();
      Options options = new Options();
      options.addOption("n",true,"Zookeeper namespace  [/DatabusClient")
      .addOption("g",true,"Groupname [default-group-name] ")
      .addOption("d",true,"Shared directory name [shareddata] ")
      .addOption("s",true,"Zookeeper server list [localhost:2181] ")
      .addOption("h",false,"help");
      CommandLine cmdLineArgs  = cmdLineParser.parse(options, args,false);
     
      if (cmdLineArgs.hasOption('h')) {
        usage();
        System.exit(0);
      }
View Full Code Here

    public void processCommandLineArgs(String[] cliArgs) throws IOException, DatabusException
    {
      constructCommandLineOptions();

      CommandLineParser cliParser = new GnuParser();

      _cmd = null;
      try
      {
        _cmd = cliParser.parse(_cliOptions, cliArgs);
      }
      catch (ParseException pe)
      {
        System.err.println("HttpServer: failed to parse command-line options: " + pe.toString());
        printCliHelp();
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static Config parseArgs(String[] args) throws Exception
  {
    CommandLineParser cliParser = new GnuParser();


    Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
        .withDescription("Help screen")
        .create(HELP_OPT_CHAR);

    Option sourceIdOption = OptionBuilder.withLongOpt(SOURCE_ID_OPT_LONG_NAME)
        .withDescription("Source ID for which tables need to be added")
        .hasArg()
        .withArgName("Source ID")
        .create(SOURCE_ID_OPT_CHAR);

    Option sourceNameOption = OptionBuilder.withLongOpt(SOURCE_NAME_OPT_LONG_NAME)
        .withDescription("Source Name for which tables need to be added")
        .hasArg()
        .withArgName("Source ID")
        .create(SOURCE_NAME_OPT_CHAR);

    Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
        .withDescription("Bootstrap producer properties to use")
        .hasArg()
        .withArgName("property_file")
        .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

    Option cmdLinePropsOption = OptionBuilder.withLongOpt(CMD_LINE_PROPS_OPT_LONG_NAME)
        .withDescription("Cmd line override of config properties. Semicolon separated.")
        .hasArg()
        .withArgName("Semicolon_separated_properties")
        .create(CMD_LINE_PROPS_OPT_CHAR);

    Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
        .withDescription("Log4j properties to use")
        .hasArg()
        .withArgName("property_file")
        .create(LOG4J_PROPS_OPT_CHAR);

    Options options = new Options();
    options.addOption(helpOption);
    options.addOption(sourceIdOption);
    options.addOption(sourceNameOption);
    options.addOption(dbOption);
    options.addOption(cmdLinePropsOption);
    options.addOption(log4jPropsOption);

    CommandLine cmd = null;
    try
    {
      cmd = cliParser.parse(options, args);
    }
    catch (ParseException pe)
    {
      LOG.error("Bootstrap Physical Config: failed to parse command-line options.", pe);
      throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here


  @SuppressWarnings("static-access")
  public static void parseArgs(String[] args) throws IOException
  {
      CommandLineParser cliParser = new GnuParser();


      Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                                     .withDescription("Help screen")
                                     .create(HELP_OPT_CHAR);

      Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
                                  .withDescription("Bootstrap Cleaner and DB properties to use")
                                  .hasArg()
                                  .withArgName("property_file")
                                  .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

      Option cmdLinePropsOption1 = OptionBuilder.withLongOpt(CLEANER_CMD_LINE_PROPS_OPT_LONG_NAME)
                      .withDescription("Cmd line override of cleaner config properties. Semicolon separated.")
                      .hasArg()
                      .withArgName("Semicolon_separated_properties")
                      .create(CLEANER_CMD_LINE_PROPS_OPT_CHAR);

    Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
                  .withDescription("Log4j properties to use")
                  .hasArg()
                  .withArgName("property_file")
                  .create(LOG4J_PROPS_OPT_CHAR);

      Option sourcesOption = OptionBuilder.withLongOpt(BOOTSTRAP_SOURCES_OPT_LONG_NAME)
              .withDescription("Comma seperated list of sourceNames. If not provided, no source will be cleaned up")
              .hasArg()
              .withArgName("comma-seperated sources")
              .create(BOOTSTRAP_SOURCES_PROP_OPT_CHAR);

      Options options = new Options();
      options.addOption(helpOption);
      options.addOption(dbOption);
      options.addOption(cmdLinePropsOption1);
    options.addOption(log4jPropsOption);
    options.addOption(sourcesOption);

      CommandLine cmd = null;
      try
      {
        cmd = cliParser.parse(options, args);
      }
      catch (ParseException pe)
      {
      LOG.error("Bootstrap Physical Config: failed to parse command-line options.", pe);
        throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static void parseArgs(String[] args) throws IOException
  {
    CommandLineParser cliParser = new GnuParser();


    Option outputDirOption = OptionBuilder.withLongOpt(OUTPUT_DIR_OPT_LONG_NAME)
        .withDescription("Help screen")
        .create(OUTPUT_DIR_OPT_CHAR);

    Options options = new Options();
    options.addOption(outputDirOption);


    CommandLine cmd = null;
    try
    {
      cmd = cliParser.parse(options, args);
    }
    catch (ParseException pe)
    {
      LOG.fatal("Bootstrap Avro Record Dumper: failed to parse command-line options.", pe);
      throw new RuntimeException("Bootstrap Avro Record Dumper: failed to parse command-line options.", pe);
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static void parseArgs(String[] args) throws IOException
  {
    CommandLineParser cliParser = new GnuParser();


        Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                                       .withDescription("Help screen")
                                       .create(HELP_OPT_CHAR);

      Option sourcesOption = OptionBuilder.withLongOpt(PHYSICAL_CONFIG_OPT_LONG_NAME)
                                     .withDescription("Bootstrap producer properties to use")
                                     .hasArg()
                                     .withArgName("property_file")
                                     .create(PHYSICAL_CONFIG_OPT_CHAR);

      Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
                      .withDescription("Bootstrap producer properties to use")
                      .hasArg()
                      .withArgName("property_file")
                      .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

      Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
                        .withDescription("Log4j properties to use")
                        .hasArg()
                        .withArgName("property_file")
                        .create(LOG4J_PROPS_OPT_CHAR);

      Options options = new Options();
      options.addOption(helpOption);
      options.addOption(sourcesOption);
      options.addOption(dbOption);
      options.addOption(log4jPropsOption);

      CommandLine cmd = null;
      try
      {
        cmd = cliParser.parse(options, args);
      }
      catch (ParseException pe)
      {
        LOG.fatal("Bootstrap Physical Config: failed to parse command-line options.", pe);
        throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static void parseArgs(String[] args) throws IOException
  {
    CommandLineParser cliParser = new GnuParser();


        Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                                       .withDescription("Help screen")
                                       .create(HELP_OPT_CHAR);

      Option sourcesOption = OptionBuilder.withLongOpt(PHYSICAL_CONFIG_OPT_LONG_NAME)
                                     .withDescription("Bootstrap producer properties to use")
                                     .hasArg()
                                     .withArgName("property_file")
                                     .create(PHYSICAL_CONFIG_OPT_CHAR);

      Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
                      .withDescription("Bootstrap producer properties to use")
                      .hasArg()
                      .withArgName("property_file")
                      .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

      Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
                        .withDescription("Log4j properties to use")
                        .hasArg()
                        .withArgName("property_file")
                        .create(LOG4J_PROPS_OPT_CHAR);

      Option validationType = OptionBuilder.withLongOpt(VALIDATION_TYPE_OPT_LONG_NAME)
                  .withDescription("Type of validation algorithm , normal[cmp two sorted streams of oracle and bootstrap db]  or point[entry in bootstrap checked in oracle]")
                  .hasArg()
                  .withArgName("validation_type")
                  .create(VALIDATION_TYPE_OPT_CHAR);

      Option validationSamplePct = OptionBuilder.withLongOpt(VALIDATION_SAMPLE_PCT_LONG_NAME)
          .withDescription("Validation sample pct ,0.0 to 100.00 [100.0]")
          .hasArg()
          .withArgName("validation_sample_pct")
          .create(VALIDATION_SAMPLE_PCT_CHAR);

      Options options = new Options();
      options.addOption(helpOption);
      options.addOption(sourcesOption);
      options.addOption(dbOption);
      options.addOption(log4jPropsOption);
      options.addOption(validationType);
      options.addOption(validationSamplePct);


      CommandLine cmd = null;
      try
      {
        cmd = cliParser.parse(options, args);
      }
      catch (ParseException pe)
      {
        LOG.fatal("Bootstrap Physical Config: failed to parse command-line options.", pe);
        throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static void parseArgs(String[] args) throws IOException
  {
    CommandLineParser cliParser = new GnuParser();

    Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                                     .withDescription("Help screen")
                                     .create(HELP_OPT_CHAR);

    Option sourcesOption = OptionBuilder.withLongOpt(QUERY_CONFIG_OPT_LONG_NAME)
                                        .withDescription("Query Config")
                                        .hasArg()
                                        .withArgName("property_file")
                                        .create(QUERY_CONFIG_OPT_CHAR);

    Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
                                   .withDescription("Bootstrap DB properties to use")
                                   .hasArg()
                                   .withArgName("property_file")
                                   .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

    Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
                                           .withDescription("Log4j properties to use")
                                           .hasArg()
                                           .withArgName("property_file")
                                           .create(LOG4J_PROPS_OPT_CHAR);
    Options options = new Options();
    options.addOption(helpOption);
    options.addOption(sourcesOption);
    options.addOption(dbOption);
    options.addOption(log4jPropsOption);

    CommandLine cmd = null;
    try
    {
      cmd = cliParser.parse(options, args);
    }
    catch (ParseException pe)
    {
      LOG.fatal("Bootstrap Physical Config: failed to parse command-line options.", pe);
      throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static int parseArgs(String[] args) throws IOException
  {
      CommandLineParser cliParser = new GnuParser();


      Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                                     .withDescription("Help screen")
                                     .create(HELP_OPT_CHAR);

      Option sourceIdOption = OptionBuilder.withLongOpt(SOURCE_ID_OPT_LONG_NAME)
                                     .withDescription("Source ID for which tables need to be dropped")
                                     .hasArg()
                                     .withArgName("Source ID")
                                     .create(SOURCE_ID_OPT_CHAR);

      Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME)
                                  .withDescription("Bootstrap producer properties to use")
                                  .hasArg()
                                  .withArgName("property_file")
                                  .create(BOOTSTRAP_DB_PROP_OPT_CHAR);

      Option cmdLinePropsOption = OptionBuilder.withLongOpt(CMD_LINE_PROPS_OPT_LONG_NAME)
                                    .withDescription("Cmd line override of config properties. Semicolon separated.")
                                    .hasArg()
                                    .withArgName("Semicolon_separated_properties")
                                    .create(CMD_LINE_PROPS_OPT_CHAR);

      Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME)
                                    .withDescription("Log4j properties to use")
                                    .hasArg()
                                    .withArgName("property_file")
                                    .create(LOG4J_PROPS_OPT_CHAR);

      Options options = new Options();
      options.addOption(helpOption);
      options.addOption(sourceIdOption);
      options.addOption(dbOption);
      options.addOption(cmdLinePropsOption);
      options.addOption(log4jPropsOption);

      CommandLine cmd = null;
      try
      {
        cmd = cliParser.parse(options, args);
      }
      catch (ParseException pe)
      {
        LOG.error("Bootstrap Physical Config: failed to parse command-line options.", pe);
        throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe);
View Full Code Here

TOP

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

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.