Examples of CommandLineParser


Examples of org.apache.commons.cli.CommandLineParser

  }

  @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

Examples of org.apache.commons.cli.CommandLineParser

  }

  @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

Examples of org.apache.commons.cli.CommandLineParser

        return ret;
    }

    public static void main(String[] args) throws Exception {
        CommandLineParser parser = new PosixParser();
        CommandLine line = null;
        try {
             line = parser.parse(options, args);
        } catch(UnrecognizedOptionException e) {
            System.err.println(e.getMessage());
            printUsage();
            return;
        }
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

      options.addOption(option);

      option = new Option("h", "help", false, "display help text");
      options.addOption(option);

      CommandLineParser parser = new GnuParser();
      CommandLine commandLine = parser.parse(options, args);

      if (commandLine.hasOption('h')) {
        new HelpFormatter().printHelp("flume-ng agent", options, true);
        return;
      }
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

    options
      .addOption("l", "dataDirs", true, "Comma-separated list of data " +
        "directories which the tool must verify. This option is mandatory")
      .addOption("h", "help", false, "Display help");

    CommandLineParser parser = new GnuParser();
    CommandLine commandLine = parser.parse(options, args);
    if(commandLine.hasOption("help")) {
      new HelpFormatter().printHelp("java -jar fcintegritytool ",
        options, true);
      return false;
    }
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

  private static URI getBaseUrl(final int port) {
    return UriBuilder.fromUri("http://0.0.0.0/").port(port).build();
  }

  public static void main(final String[] args) throws Exception {
    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(options(), args);
   
    int port = Integer.parseInt(cmd.getOptionValue("port", "8080"));
    String dbHost = cmd.getOptionValue("dbhost", "localhost");
    int dbPort = Integer.parseInt(cmd.getOptionValue("dbport", "3306"));
   
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

    options.addOption(opt);
    options.addOption(opt);
    opt = new Option("t", true, "capacity of the channel");
    opt.setRequired(true);
    options.addOption(opt);
    CommandLineParser parser = new GnuParser();
    CommandLine cli = parser.parse(options, args);
    File checkpointDir = new File(cli.getOptionValue("c"));
    String[] logDirs = cli.getOptionValue("l").split(",");
    List<File> logFiles = Lists.newArrayList();
    for (String logDir : logDirs) {
      logFiles.addAll(LogUtils.getLogs(new File(logDir)));
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

        .withDescription("output repair file (can be used later as a data file)")
        .create(REPAIR_OPTION));
    options.addOption(NOFOLLOW_OPTION, NOFOLLOW_OPTION, false, "don't follow 301 redirects");

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
      System.err.println("Error parsing command line: " + exp.getMessage());
      System.exit(-1);
    }
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

   
    public static void main(String[] args) throws Exception {
      Options options = getOptions();
      try {
       
        CommandLineParser parser = new GnuParser();

        CommandLine line = parser.parse( options, args );
        File dir = new File(line.getOptionValue("dir", "."));
        String name = line.getOptionValue("name", "jar");
        System.out.println("total size of files in "+dir+" containing "+name+": "+SizeWhere.totalSize(dir, name));
      } catch( ParseException exp ) {
          // oops, something went wrong
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

   
    public static void main(String[] args) throws Exception {
        Options options = getOptions();
        try {
       
            CommandLineParser parser = new GnuParser();
   
            CommandLine line = parser.parse(options, args);
            File dir = new File(line.getOptionValue("dir", "."));
            String name = line.getOptionValue("name", "jar");
            Collection files = FindFile.find(dir, name);
            System.out.println("listing files in " + dir + " containing " + name);
            for (Iterator it = files.iterator(); it.hasNext();) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.