Package org.apache.commons.cli

Examples of org.apache.commons.cli.CommandLine


    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);
    }

    if (cmd.hasOption(OUTPUT_DIR_OPT_CHAR))
    {
      outputDir = cmd.getOptionValue(OUTPUT_DIR_OPT_CHAR);
    }
  }
View Full Code Here


    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("i", "dictionaryPath", true, "Directory path where the dictionary files are stored.");
    options.addOption("o", "outputPath", true, "Output directory path where the RDF representation of dictionaries will be created.");
    options.addOption("c", "catalog Path", true, "Output directory path where the catalog file will be created.");
    options.addOption("f", "format", true, "RDF format for serialization (RDF/XML, TURTLE, N-TRIPLES).");
    CommandLine commandLine = parser.parse( options, args );

    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('i'))
      dictionaryPath = commandLine.getOptionValue('i');
   
    if(commandLine.hasOption('o'))
      outputFilePath = commandLine.getOptionValue('o');
   
    if(commandLine.hasOption('f'))
      serialization = commandLine.getOptionValue('f');
   
    if(commandLine.hasOption('c'))
      catalogPath = commandLine.getOptionValue('c');
   
    if(dictionaryPath.equals("") || outputFilePath.equals("") || serialization.equals("") || catalogPath.equals(""))
    {
      usage();
      return;
View Full Code Here

      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);
      }

      if (cmd.hasOption(LOG4J_PROPS_OPT_CHAR))
      {
        String log4jPropFile = cmd.getOptionValue(LOG4J_PROPS_OPT_CHAR);
        PropertyConfigurator.configure(log4jPropFile);
        LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
        PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
        ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

        Logger.getRootLogger().removeAllAppenders();
        Logger.getRootLogger().addAppender(defaultAppender);
        Logger.getRootLogger().setLevel(Level.INFO)//using info as the default log level
        LOG.info("Using default logging settings. Log Level is :" + Logger.getRootLogger().getLevel());
      }

      if (cmd.hasOption(HELP_OPT_CHAR))
      {
        printCliHelp(options);
        System.exit(0);
      }

      if (! cmd.hasOption(PHYSICAL_CONFIG_OPT_CHAR))
        throw new RuntimeException("Sources Config is not provided; use --help for usage");

      if (!cmd.hasOption(BOOTSTRAP_DB_PROP_OPT_CHAR) )
        throw new RuntimeException("Bootstrap config is not provided; use --help for usage");

      _sSourcesConfigFile = cmd.getOptionValue(PHYSICAL_CONFIG_OPT_CHAR);

      String propFile = cmd.getOptionValue(BOOTSTRAP_DB_PROP_OPT_CHAR);
      LOG.info("Loading bootstrap DB config from properties file " + propFile);

      _sBootstrapConfigProps = new Properties();
      FileInputStream fis = new FileInputStream(propFile);
      try
View Full Code Here

    Options options = new Options( );
    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("p", "path", true, "Directory path for downloading the zip files.");
    options.addOption("t", "path", true, "Directory path for downloading the compressed tsv files.");
   
    CommandLine commandLine = parser.parse( options, args );

    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('p'))
      filePath = commandLine.getOptionValue('p');
   
    if(commandLine.hasOption('t'))
      tsvFilePath = commandLine.getOptionValue('t');
   
    if(filePath.equals("") || tsvFilePath.equals(""))
    {
      usage();
      return;
View Full Code Here

    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("p", "path", true, "Directory path for downloading the compressed zip files.");
    options.addOption("u", "zip", true, "URL of the compressed file.");
    options.addOption("t", "tsv", true, "Directory path for downloading the compressed tsv files.");
   
    CommandLine commandLine = parser.parse( options, args );

    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('p'))
      tmpZipPath = commandLine.getOptionValue('p');
   
    if(commandLine.hasOption('u'))
      url = commandLine.getOptionValue('u');
   
    if(commandLine.hasOption('t'))
      tmpTsvPath = commandLine.getOptionValue('t');
   
    if(tmpZipPath.equals("") || url.equals("") || tmpTsvPath.equals(""))
    {
      usage();
      return;
View Full Code Here

    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("i", "inputFilepath", true, "Data Structure Definition (DSD) in XML format as input.");
    options.addOption("o", "outputFilePath", true, "Output directory path to generate DataCube representation of DSD.");
    options.addOption("f", "format", true, "RDF format for serialization (RDF/XML, TURTLE, N-TRIPLES).");
    options.addOption("a", "sdmx ttl file", true, "Path where the sdmx ttl is located.");
    CommandLine commandLine = parser.parse( options, args );
   
    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('i'))
      xmlFilePath = commandLine.getOptionValue('i');
    if(commandLine.hasOption('o'))
      outputFilePath = commandLine.getOptionValue('o');
    if(commandLine.hasOption('f'))
      serialization = commandLine.getOptionValue('f');
   
    if(commandLine.hasOption('a'))
      sdmx_codeFilePath = commandLine.getOptionValue('a');
   
    if(xmlFilePath.equals("") || outputFilePath.equals("") || serialization.equals("") || sdmx_codeFilePath.equals(""))
    {
      usage();
      return;
View Full Code Here

        Options options = new Options( );
        options.addOption("h", "help", false, "Print this usage information");
        options.addOption("i", "inputFilepath", true, "Local ToC file.");
        options.addOption("o", "outputFilepath", true, "Output directory path to generate the metadata files.");
        options.addOption("f", "format", true, "RDF format for serialization (RDF/XML, TURTLE, N-TRIPLES).");
        CommandLine commandLine = parser.parse( options, args );

        if( commandLine.hasOption('h') ) {
            usage();
            return;
         }

        if(commandLine.hasOption('i'))
            inputFilePath = commandLine.getOptionValue('i');
        if(commandLine.hasOption('o'))
            outputFilePath = commandLine.getOptionValue('o');
        if(commandLine.hasOption('f'))
            serialization = commandLine.getOptionValue('f');

        if(outputFilePath.equals("") || serialization.equals(""))
        {
            usage();
            return;
View Full Code Here

    CommandLineParser parser = new BasicParser( );
    Options options = new Options( );
    options.addOption("h", "help", false, "Print this usage information");
    options.addOption("n", "num", true, "No. of Dataset URLs to print. Default sets to 10.");

    CommandLine commandLine = parser.parse( options, args );
   
    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('n'))
      printDatasets = Integer.parseInt(commandLine.getOptionValue('n'));
   
    obj.parseToC();
  }
View Full Code Here

    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);
    }

    if (cmd.hasOption(LOG4J_PROPS_OPT_CHAR))
    {
      String log4jPropFile = cmd.getOptionValue(LOG4J_PROPS_OPT_CHAR);
      PropertyConfigurator.configure(log4jPropFile);
      LOG.info("Using custom logging settings from file " + log4jPropFile);
    }
    else
    {
      PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
      ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

      Logger.getRootLogger().removeAllAppenders();
      Logger.getRootLogger().addAppender(defaultAppender);

      LOG.info("Using default logging settings");
    }

    if (cmd.hasOption(HELP_OPT_CHAR))
    {
      printCliHelp(options);
      System.exit(0);
    }

    if (!cmd.hasOption(QUERY_CONFIG_OPT_CHAR))
    {
      throw new RuntimeException("Query Config is not provided; use --help for usage");
    }

    if (!cmd.hasOption(BOOTSTRAP_DB_PROP_OPT_CHAR))
    {
      throw new RuntimeException("Bootstrap config is not provided; use --help for usage");
    }

    String propFile1 = cmd.getOptionValue(QUERY_CONFIG_OPT_CHAR);
    String propFile2 = cmd.getOptionValue(BOOTSTRAP_DB_PROP_OPT_CHAR);
    LOG.info("Loading bootstrap DB config from properties file " + propFile2);

    _sQueryConfigProps = new Properties();
    FileInputStream f1 = new FileInputStream(propFile1);
    try
View Full Code Here

      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);
      }

      if (cmd.hasOption(LOG4J_PROPS_OPT_CHAR))
      {
          String log4jPropFile = cmd.getOptionValue(LOG4J_PROPS_OPT_CHAR);
          PropertyConfigurator.configure(log4jPropFile);
          LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
          PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
          ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

          Logger.getRootLogger().removeAllAppenders();
          Logger.getRootLogger().addAppender(defaultAppender);

          LOG.info("Using default logging settings");
      }

      if (cmd.hasOption(HELP_OPT_CHAR))
      {
        printCliHelp(options);
        System.exit(0);
      }

      if ( !cmd.hasOption(SOURCE_ID_OPT_CHAR))
        throw new RuntimeException("Source ID is not provided");

      if (!cmd.hasOption(BOOTSTRAP_DB_PROP_OPT_CHAR) )
          throw new RuntimeException("Bootstrap config is not provided");

      String propFile = cmd.getOptionValue(BOOTSTRAP_DB_PROP_OPT_CHAR);
      LOG.info("Loading bootstrap DB config from properties file " + propFile);

      _sBootstrapConfigProps = new Properties();
    FileInputStream f = new FileInputStream(propFile);
    try
    {
    _sBootstrapConfigProps.load(f);
    } finally {
    f.close();
    }
   
      if (cmd.hasOption(CMD_LINE_PROPS_OPT_CHAR))
      {
        String cmdLinePropString = cmd.getOptionValue(CMD_LINE_PROPS_OPT_CHAR);
        updatePropsFromCmdLine(_sBootstrapConfigProps, cmdLinePropString);
      }

      return Integer.parseInt(cmd.getOptionValue(SOURCE_ID_OPT_CHAR));
  }
View Full Code Here

TOP

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

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.