Ejemplo n.º 1
0
 private boolean parseAndPrimeWith(
     final Options options, final List<OptionHandler> optionHandlers, final String[] args) {
   final BootPrinter printer = new BootPrinter(getClass());
   final CommandLineParser parser = new BasicParser();
   try {
     final CommandLine commandLine = parser.parse(options, args);
     for (final OptionHandler optionHandler : optionHandlers) {
       if (!optionHandler.handle(commandLine, printer, options)) {
         return false;
       }
     }
   } catch (final ParseException e) {
     printer.printErrorMessage(e.getMessage());
     printer.printHelp(options);
     return false;
   }
   return true;
 }
Ejemplo n.º 2
0
  public boolean parseAndPrimeWith(final List<OptionHandler> optionHandlers, final String[] args) {

    // add options (ie cmd line flags)
    final Options options = new Options();
    for (final OptionHandler optionHandler : optionHandlers) {
      optionHandler.addOption(options);
    }

    // parse options from the cmd line
    final boolean parsedOk = parseAndPrimeWith(options, optionHandlers, args);

    if (parsedOk) {
      for (final OptionHandler optionHandler : optionHandlers) {
        primeWith(optionHandler);
      }
    }

    return parsedOk;
  }