Examples of CommandLine


Examples of org.apache.commons.cli.CommandLine

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

    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(SOURCE_NAME_OPT_CHAR))
      throw new RuntimeException("Source Name 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);
    }

    int srcId = Integer.parseInt(cmd.getOptionValue(SOURCE_ID_OPT_CHAR));
    String srcName = cmd.getOptionValue(SOURCE_NAME_OPT_CHAR);

    BootstrapConfig config = new BootstrapConfig();

    ConfigLoader<BootstrapReadOnlyConfig> configLoader =
        new ConfigLoader<BootstrapReadOnlyConfig>("bootstrap.", config);
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    options.addOption("i", "file path", true, "File path of the SDMX xml file.");
    options.addOption("t", "tsv file path", true, "File path of the SDMX tsv file.");
    options.addOption("o", "output file path", true, "Output directory path to generate DataCube representation of observations");
    options.addOption("l", "log file path", true, "File path where the logs will be written.");
   
    CommandLine commandLine = parser.parse( options, args );
   
    if( commandLine.hasOption('h') ) {
        usage();
        return;
     }
   
    if(commandLine.hasOption('f'))
      fileName = commandLine.getOptionValue('f');
   
    if(commandLine.hasOption('i'))
      sdmxFilePath = commandLine.getOptionValue('i');
   
    if(commandLine.hasOption('t'))
      tsvFilePath = commandLine.getOptionValue('t');
   
    if(commandLine.hasOption('o'))
      outputFilePath = commandLine.getOptionValue('o');
   
    if(commandLine.hasOption('l'))
      logFilePath = commandLine.getOptionValue('l');
   
   
    if(tsvFilePath.equals("") || fileName.equals("") || sdmxFilePath.equals("") || outputFilePath.equals("") || logFilePath.equals(""))
    {
      usage();
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    @Override
    public void processCommandLineArgs(String[] cliArgs) throws IOException, DatabusException
    {
      super.processCommandLineArgs(cliArgs);
      CommandLine cmdLine = getCmdLine();

      if (! cmdLine.hasOption(ACTION_OPTION_CHAR))
      {
        throw new DatabusException("action expected; see --help for usage");
      }
      String actionString = cmdLine.getOptionValue(ACTION_OPTION_CHAR).toUpperCase();

      try
      {
        _action = Action.valueOf(actionString);
      }
      catch (IllegalArgumentException e)
      {
        throw new DatabusException("invalid action: " + actionString);
      }

      if (_action.equals(Action.CREATE_LOG_TABLE) || _action.equals(Action.CREATE_TAB_TABLE))
      {
        if (! cmdLine.hasOption(SRCID_OPTION_CHAR))
        {
          throw new DatabusException("srcid expected; see --help for usage");
        }
        String srcidString = cmdLine.getOptionValue(SRCID_OPTION_CHAR);

        try
        {
          _srcId = Integer.parseInt(srcidString);
        }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

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

      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(BOOTSTRAP_SOURCES_PROP_OPT_CHAR))
      {
        _sSources = new ArrayList<String>();
        String srcListStr = cmd.getOptionValue(BOOTSTRAP_SOURCES_PROP_OPT_CHAR);
          LOG.info("Going to run cleaner for only these sources : " + srcListStr);
          String[] srcList = srcListStr.split(",");
          for (String s: srcList)
            _sSources.add(s);
      }

      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(CLEANER_CMD_LINE_PROPS_OPT_CHAR))
      {
        String cmdLinePropString = cmd.getOptionValue(CLEANER_CMD_LINE_PROPS_OPT_CHAR);
        updatePropsFromCmdLine(_sBootstrapConfigProps, cmdLinePropString);
      }
  }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    Options options = new Options( );
   
    options.addOption("i", "file path", true, "sdmx file path.");
    options.addOption("l", "log file path", true, "File path where the logs will be generated");
   
    CommandLine commandLine = parser.parse( options, args );
   
    if(commandLine.hasOption('i'))
      sdmxFilePath = commandLine.getOptionValue('i');
       
    if(commandLine.hasOption('l'))
      logFilePath = commandLine.getOptionValue('l');
   
    if(sdmxFilePath.equals("") || logFilePath.equals(""))
    {
     
      return;
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

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

      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();
      _sBootstrapConfigProps.load(new FileInputStream(propFile));
      if (!cmd.hasOption(VALIDATION_TYPE_OPT_CHAR))
      {
        _validationType = "normal";
      }
      else
      {
        String vtype = cmd.getOptionValue(VALIDATION_TYPE_OPT_CHAR);
        if (vtype.equals("point") || vtype.equals("normal") || vtype.equals("pointBs"))
        {
          _validationType = vtype;
        }
        else
        {
          throw new RuntimeException("Validation type has to be one of 'normal' or 'point' or 'pointBs'");
        }
      }
      if (cmd.hasOption(VALIDATION_SAMPLE_PCT_CHAR))
      {
         try
         {
           _validationSamplePct = Double.parseDouble(cmd.getOptionValue(VALIDATION_SAMPLE_PCT_CHAR));
           if (_validationSamplePct < 0.0 || _validationSamplePct > 100.0)
           {
             throw new RuntimeException("Error in specifying: " + VALIDATION_SAMPLE_PCT_LONG_NAME +
                 "Should be between 0.0 and 100.0. It was " + _validationSamplePct);
           }
View Full Code Here

Examples of org.apache.commons.cli.CommandLine

    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 file.");
    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(serialization.equals("") || outputFilePath.equals(""))
    {
      usage();
      return;
View Full Code Here

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

Examples of org.apache.commons.cli.CommandLine

    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

Examples of org.apache.commons.cli.CommandLine

      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
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.