List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:com.esri.geoevent.test.performance.OrchestratorMain.java
/** * Main method - this is used to when running from command line * * @param args Command Line Arguments//w w w.j a v a 2 s . c o m */ @SuppressWarnings("static-access") public static void main(String[] args) { // TODO: Localize the messages // test harness options Options testHarnessOptions = new Options(); testHarnessOptions.addOption(OptionBuilder.withLongOpt("fixtures") .withDescription("The fixtures xml file to load and configure the performance test harness.") .hasArg().create("f")); testHarnessOptions.addOption("h", "help", false, "print the help message"); // parse the command line CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(testHarnessOptions, args, false); } catch (ParseException ignore) { printHelp(testHarnessOptions); return; } if (cmd.getOptions().length == 0) { OrchestratorUI ui = new OrchestratorUI(); ui.run(args); } else { if (cmd.hasOption("h")) { printHelp(testHarnessOptions); return; } if (cmd.hasOption("h") || !cmd.hasOption("f")) { printHelp(testHarnessOptions); return; } String fixturesFilePath = cmd.getOptionValue("f"); // validate if (!validateFixturesFile(fixturesFilePath)) { printHelp(testHarnessOptions); return; } // parse the xml file final Fixtures fixtures; try { fixtures = fromXML(fixturesFilePath); } catch (JAXBException error) { System.err.println(ImplMessages.getMessage("TEST_HARNESS_EXECUTOR_CONFIG_ERROR", fixturesFilePath)); error.printStackTrace(); return; } // run the test harness try { OrchestratorRunner executor = new OrchestratorRunner(fixtures); executor.start(); } catch (RunningException error) { error.printStackTrace(); } } }
From source file:com.cloudera.impala.testutil.SentryServiceWrapper.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { // Parse command line options to get config file path. Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("config_file") .withDescription("Absolute path to a sentry-site.xml config file").hasArg() .withArgName("CONFIG_FILE").isRequired().create('c')); BasicParser optionParser = new BasicParser(); CommandLine cmdArgs = optionParser.parse(options, args); SentryServiceWrapper server = new SentryServiceWrapper( new SentryConfig(cmdArgs.getOptionValue("config_file"))); server.start();/* www. j av a 2 s .c o m*/ }
From source file:edu.cmu.lti.oaqa.annographix.apps.SolrIndexApp.java
public static void main(String[] args) { Options options = new Options(); options.addOption("t", null, true, "Text File"); options.addOption("a", null, true, "Annotation File"); options.addOption("u", null, true, "Solr URI"); options.addOption("n", null, true, "Batch size"); options.addOption(/*from w w w . ja va 2s . c o m*/ OptionBuilder.withLongOpt(TEXT_FIELD_ARG).withDescription("Text field name").hasArg().create()); options.addOption(OptionBuilder.withLongOpt(ANNOT_FIELD_ARG).withDescription("Annotation field name") .hasArg().create()); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("t")) { docTextFile = cmd.getOptionValue("t"); } else { Usage("Specify Text File"); } if (cmd.hasOption("a")) { docAnnotFile = cmd.getOptionValue("a"); } else { Usage("Specify Annotation File"); } if (cmd.hasOption("u")) { solrURI = cmd.getOptionValue("u"); } else { Usage("Specify Solr URI"); } if (cmd.hasOption("n")) { batchQty = Integer.parseInt(cmd.getOptionValue("n")); } String textFieldName = UtilConst.DEFAULT_TEXT4ANNOT_FIELD; String annotFieldName = UtilConst.DEFAULT_ANNOT_FIELD; if (cmd.hasOption(TEXT_FIELD_ARG)) { textFieldName = cmd.getOptionValue(TEXT_FIELD_ARG); } if (cmd.hasOption(ANNOT_FIELD_ARG)) { annotFieldName = cmd.getOptionValue(ANNOT_FIELD_ARG); } System.out.println(String.format("Annotated text field: '%s', annotation field: '%s'", textFieldName, annotFieldName)); // Ignoring return value here SolrUtils.parseAndCheckConfig(solrURI, textFieldName, annotFieldName); System.out.println("Config is fine!"); DocumentReader.readDoc(docTextFile, textFieldName, docAnnotFile, batchQty, new SolrDocumentIndexer(solrURI, textFieldName, annotFieldName)); } catch (ParseException e) { Usage("Cannot parse arguments"); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:CircularGenerator.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { Options helpOptions = new Options(); helpOptions.addOption("h", "help", false, "show this help page"); Options options = new Options(); options.addOption("h", "help", false, "show this help page"); options.addOption(OptionBuilder.withLongOpt("input").withArgName("INPUT") .withDescription("the input FastA File").isRequired().hasArg().create("i")); options.addOption(OptionBuilder.withLongOpt("elongation").withArgName("ELONGATION") .withDescription("the elongation factor [INT]").isRequired().hasArg().create("e")); options.addOption(OptionBuilder.withLongOpt("seq").withArgName("SEQ") .withDescription("the names of the sequences that should to be elongated").isRequired().hasArg() .hasOptionalArgs().hasArg().create("s")); HelpFormatter helpformatter = new HelpFormatter(); CommandLineParser parser = new BasicParser(); try {/*from w w w . jav a2s .c o m*/ CommandLine cmd = parser.parse(helpOptions, args); if (cmd.hasOption('h')) { helpformatter.printHelp(CLASS_NAME + "v" + VERSION, options); System.exit(0); } } catch (ParseException e1) { } String input = ""; String tmpElongation = ""; Integer elongation = 0; String[] names = new String[0]; try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('i')) { input = cmd.getOptionValue('i'); } if (cmd.hasOption('e')) { tmpElongation = cmd.getOptionValue('e'); try { elongation = Integer.parseInt(tmpElongation); } catch (Exception e) { System.err.println("elongation not an Integer: " + tmpElongation); System.exit(0); } } if (cmd.hasOption('s')) { names = cmd.getOptionValues('s'); } } catch (ParseException e) { helpformatter.printHelp(CLASS_NAME, options); System.err.println(e.getMessage()); System.exit(0); } CircularGenerator cg = new CircularGenerator(elongation); File f = new File(input); for (String s : names) { cg.keys_to_treat_circular.add(s); } cg.extendFastA(f); }
From source file:de.tudarmstadt.lt.lm.app.GenerateNgrams.java
@SuppressWarnings("static-access") public static void main(String[] args) { Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?")); opts.addOption(OptionBuilder.withLongOpt("ptype").withArgName("class").hasArg().withDescription( "specify the instance of the language model provider that you want to use: {LtSegProvider, BreakIteratorStringProvider, UimaStringProvider, PreTokenizedStringProvider} (default: LtSegProvider)") .create("p")); opts.addOption(OptionBuilder.withLongOpt("cardinality").withArgName("ngram-order").hasArg().withDescription( "Specify the cardinality of the ngrams (min. 1). Specify a range using 'from-to'. (Examples: 5 = extract 5grams; 1-5 = extract 1grams, 2grams, ..., 5grams; default: 1-5).") .create("n")); opts.addOption(OptionBuilder.withLongOpt("dir").withArgName("directory").isRequired().hasArg() .withDescription(/*w ww . jav a 2s . co m*/ "specify the directory that contains '.txt' files that are used as source for generating ngrams.") .create("d")); opts.addOption(OptionBuilder.withLongOpt("overwrite").withDescription("Overwrite existing ngram file.") .create("w")); CommandLine cli = null; try { cli = new GnuParser().parse(opts, args); } catch (Exception e) { print_usage(opts, e.getMessage()); } if (cli.hasOption("?")) print_usage(opts, null); AbstractStringProvider prvdr = null; try { prvdr = StartLM .getStringProviderInstance(cli.getOptionValue("ptype", LtSegProvider.class.getSimpleName())); } catch (Exception e) { print_usage(opts, String.format("Could not instantiate LmProvider '%s': %s", cli.getOptionValue("ptype", LtSegProvider.class.getSimpleName()), e.getMessage())); } String n_ = cli.getOptionValue("cardinality", "1-5"); int dash_index = n_.indexOf('-'); int n_e = Integer.parseInt(n_.substring(dash_index + 1, n_.length()).trim()); int n_b = n_e; if (dash_index == 0) n_b = 1; if (dash_index > 0) n_b = Math.max(1, Integer.parseInt(n_.substring(0, dash_index).trim())); final File src_dir = new File(cli.getOptionValue("dir")); boolean overwrite = Boolean.parseBoolean(cli.getOptionValue("overwrite", "false")); generateNgrams(src_dir, prvdr, n_b, n_e, overwrite); }
From source file:com.gordcorp.jira2db.App.java
public static void main(String[] args) throws Exception { File log4jFile = new File("log4j.xml"); if (log4jFile.exists()) { DOMConfigurator.configure("log4j.xml"); }//from ww w .j a va 2 s . c o m Option help = new Option("h", "help", false, "print this message"); @SuppressWarnings("static-access") Option project = OptionBuilder.withLongOpt("project").withDescription("Only sync Jira project PROJECT") .hasArg().withArgName("PROJECT").create(); @SuppressWarnings("static-access") Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator() .withDescription("use value for given property").create("D"); @SuppressWarnings("static-access") Option testJira = OptionBuilder.withLongOpt("test-jira") .withDescription("Test the connection to Jira and print the results").create(); @SuppressWarnings("static-access") Option forever = OptionBuilder.withLongOpt("forever") .withDescription("Will continue polling Jira and syncing forever").create(); Options options = new Options(); options.addOption(help); options.addOption(project); options.addOption(property); options.addOption(testJira); options.addOption(forever); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption(help.getOpt())) { printHelp(options); return; } // Overwrite the properties file with command line arguments if (line.hasOption("D")) { String[] values = line.getOptionValues("D"); for (int i = 0; i < values.length; i = i + 2) { String key = values[i]; // If user does not provide a value for this property, use // an empty string String value = ""; if (i + 1 < values.length) { value = values[i + 1]; } log.info("Setting key=" + key + " value=" + value); PropertiesWrapper.set(key, value); } } if (line.hasOption("test-jira")) { testJira(); } else { JiraSynchroniser jira = new JiraSynchroniser(); if (line.hasOption("project")) { jira.setProjects(Arrays.asList(new String[] { line.getOptionValue("project") })); } if (line.hasOption("forever")) { jira.syncForever(); } else { jira.syncAll(); } } } catch (ParseException exp) { log.error("Parsing failed: " + exp.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:com.dhenton9000.screenshots.ScreenShotLauncher.java
/** * main launching method that takes command line arguments * * @param args//from www .j av a2s.com */ public static void main(String[] args) { final String[] actions = { ACTIONS.source.toString(), ACTIONS.target.toString(), ACTIONS.compare.toString() }; final List actionArray = Arrays.asList(actions); Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("action").hasArg().isRequired().withArgName("action").create()); HelpFormatter formatter = new HelpFormatter(); String header = "Process screenshots\n" + "--action=source create source screenshots\n" + "--action=target create the screenshots for comparison\n" + "--action=compare compare the images\n" + "%s\n\n"; String action = null; try { // parse the command line arguments CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options, args); // validate that action option has been set if (line.hasOption("action")) { action = line.getOptionValue("action"); LOG.debug("action '" + action + "'"); if (!actionArray.contains(action)) { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, String.format("action option '%s' is invalid", action)), options, "\n\n", true); System.exit(1); } } else { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, "not found"), options, "\n\n", false); System.exit(1); } } catch (ParseException exp) { formatter.printHelp(ScreenShotLauncher.class.getName(), String.format(header, "problem " + exp.getMessage()), options, "\n\n", false); System.exit(1); } ACTIONS actionEnum = ACTIONS.valueOf(action); ScreenShotLauncher launcher = new ScreenShotLauncher(); try { launcher.handleRequest(actionEnum); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } }
From source file:apps.classification.LearnSVMPerf.java
public static void main(String[] args) throws IOException { String cmdLineSyntax = LearnSVMPerf.class.getName() + " [OPTIONS] <path to svm_perf> <trainingIndexDirectory>"; Options options = new Options(); OptionBuilder.withArgName("c"); OptionBuilder.withDescription("The c value for svm_perf (default 0.01)"); OptionBuilder.withLongOpt("c"); OptionBuilder.isRequired(false);/*from ww w.j a va 2s. com*/ OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("t"); OptionBuilder.withDescription("Path for temporary files"); OptionBuilder.withLongOpt("t"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("l"); OptionBuilder.withDescription("The loss function to optimize (default 2):\n" + " 0 Zero/one loss: 1 if vector of predictions contains error, 0 otherwise.\n" + " 1 F1: 100 minus the F1-score in percent.\n" + " 2 Errorrate: Percentage of errors in prediction vector.\n" + " 3 Prec/Rec Breakeven: 100 minus PRBEP in percent.\n" + " 4 Prec@p: 100 minus precision at p in percent.\n" + " 5 Rec@p: 100 minus recall at p in percent.\n" + " 10 ROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea)."); OptionBuilder.withLongOpt("l"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("w"); OptionBuilder.withDescription("Choice of structural learning algorithm (default 9):\n" + " 0: n-slack algorithm described in [2]\n" + " 1: n-slack algorithm with shrinking heuristic\n" + " 2: 1-slack algorithm (primal) described in [5]\n" + " 3: 1-slack algorithm (dual) described in [5]\n" + " 4: 1-slack algorithm (dual) with constraint cache [5]\n" + " 9: custom algorithm in svm_struct_learn_custom.c"); OptionBuilder.withLongOpt("w"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("p"); OptionBuilder.withDescription("The value of p used by the prec@p and rec@p loss functions (default 0)"); OptionBuilder.withLongOpt("p"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("v"); OptionBuilder.withDescription("Verbose output"); OptionBuilder.withLongOpt("v"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("s"); OptionBuilder.withDescription("Don't delete temporary training file in svm_perf format (default: delete)"); OptionBuilder.withLongOpt("s"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); SvmPerfLearnerCustomizer classificationLearnerCustomizer = null; GnuParser parser = new GnuParser(); String[] remainingArgs = null; try { CommandLine line = parser.parse(options, args); remainingArgs = line.getArgs(); classificationLearnerCustomizer = new SvmPerfLearnerCustomizer(remainingArgs[0]); if (line.hasOption("c")) classificationLearnerCustomizer.setC(Float.parseFloat(line.getOptionValue("c"))); if (line.hasOption("w")) classificationLearnerCustomizer.setW(Integer.parseInt(line.getOptionValue("w"))); if (line.hasOption("p")) classificationLearnerCustomizer.setP(Integer.parseInt(line.getOptionValue("p"))); if (line.hasOption("l")) classificationLearnerCustomizer.setL(Integer.parseInt(line.getOptionValue("l"))); if (line.hasOption("v")) classificationLearnerCustomizer.printSvmPerfOutput(true); if (line.hasOption("s")) classificationLearnerCustomizer.setDeleteTrainingFiles(false); if (line.hasOption("t")) classificationLearnerCustomizer.setTempPath(line.getOptionValue("t")); } catch (Exception exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } if (remainingArgs.length != 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } String indexFile = remainingArgs[1]; File file = new File(indexFile); String indexName = file.getName(); String indexPath = file.getParent(); // LEARNING SvmPerfLearner classificationLearner = new SvmPerfLearner(); classificationLearner.setRuntimeCustomizer(classificationLearnerCustomizer); FileSystemStorageManager storageManager = new FileSystemStorageManager(indexPath, false); storageManager.open(); IIndex training = TroveReadWriteHelper.readIndex(storageManager, indexName, TroveContentDBType.Full, TroveClassificationDBType.Full); storageManager.close(); IClassifier classifier = classificationLearner.build(training); File executableFile = new File(classificationLearnerCustomizer.getSvmPerfLearnPath()); SvmPerfDataManager dataManager = new SvmPerfDataManager(new SvmPerfClassifierCustomizer( executableFile.getParentFile().getAbsolutePath() + Os.pathSeparator() + "svm_perf_classify")); String description = "_SVMPerf_C-" + classificationLearnerCustomizer.getC() + "_W-" + classificationLearnerCustomizer.getW() + "_L-" + classificationLearnerCustomizer.getL(); if (classificationLearnerCustomizer.getL() == 4 || classificationLearnerCustomizer.getL() == 5) description += "_P-" + classificationLearnerCustomizer.getP(); if (classificationLearnerCustomizer.getAdditionalParameters().length() > 0) description += "_" + classificationLearnerCustomizer.getAdditionalParameters(); storageManager = new FileSystemStorageManager(indexPath, false); storageManager.open(); dataManager.write(storageManager, indexName + description, classifier); storageManager.close(); }
From source file:eu.fbk.utils.twm.FormPageSearcher.java
public static void main(final String args[]) throws Exception { String logConfig = System.getProperty("log-config"); if (logConfig == null) { logConfig = "configuration/log-config.txt"; }/*from www . j ava 2 s .c o m*/ PropertyConfigurator.configure(logConfig); final Options options = new Options(); try { OptionBuilder.withArgName("index"); OptionBuilder.hasArg(); OptionBuilder.withDescription("open an index with the specified name"); OptionBuilder.isRequired(); OptionBuilder.withLongOpt("index"); final Option indexNameOpt = OptionBuilder.create("i"); OptionBuilder.withArgName("interactive-mode"); OptionBuilder.withDescription("enter in the interactive mode"); OptionBuilder.withLongOpt("interactive-mode"); final Option interactiveModeOpt = OptionBuilder.create("t"); OptionBuilder.withArgName("search"); OptionBuilder.hasArg(); OptionBuilder.withDescription("search for the specified key"); OptionBuilder.withLongOpt("search"); final Option searchOpt = OptionBuilder.create("s"); OptionBuilder.withArgName("key-freq"); OptionBuilder.hasArg(); OptionBuilder.withDescription("read the keys' frequencies from the specified file"); OptionBuilder.withLongOpt("key-freq"); final Option freqFileOpt = OptionBuilder.create("f"); OptionBuilder.withArgName("minimum-freq"); // Option keyFieldNameOpt = // OptionBuilder.withArgName("key-field-name").hasArg().withDescription("use the specified name for the field key").withLongOpt("key-field-name").create("k"); // Option valueFieldNameOpt = // OptionBuilder.withArgName("value-field-name").hasArg().withDescription("use the specified name for the field value").withLongOpt("value-field-name").create("v"); final Option minimumKeyFreqOpt = OptionBuilder.hasArg() .withDescription("minimum key frequency of cached values (default is " + DEFAULT_MIN_FREQ + ")") .withLongOpt("minimum-freq").create("m"); OptionBuilder.withArgName("int"); final Option notificationPointOpt = OptionBuilder.hasArg() .withDescription( "receive notification every n pages (default is " + DEFAULT_NOTIFICATION_POINT + ")") .withLongOpt("notification-point").create("b"); options.addOption("h", "help", false, "print this message"); options.addOption("v", "version", false, "output version information and exit"); options.addOption(indexNameOpt); options.addOption(interactiveModeOpt); options.addOption(searchOpt); options.addOption(freqFileOpt); // options.addOption(keyFieldNameOpt); // options.addOption(valueFieldNameOpt); options.addOption(minimumKeyFreqOpt); options.addOption(notificationPointOpt); final CommandLineParser parser = new PosixParser(); final CommandLine line = parser.parse(options, args); if (line.hasOption("help") || line.hasOption("version")) { throw new ParseException(""); } int minFreq = DEFAULT_MIN_FREQ; if (line.hasOption("minimum-freq")) { minFreq = Integer.parseInt(line.getOptionValue("minimum-freq")); } int notificationPoint = DEFAULT_NOTIFICATION_POINT; if (line.hasOption("notification-point")) { notificationPoint = Integer.parseInt(line.getOptionValue("notification-point")); } final FormPageSearcher pageFormSearcher = new FormPageSearcher(line.getOptionValue("index")); pageFormSearcher.setNotificationPoint(notificationPoint); /* * logger.debug(line.getOptionValue("key-field-name") + "\t" + * line.getOptionValue("value-field-name")); if (line.hasOption("key-field-name")) { * pageFormSearcher.setKeyFieldName(line.getOptionValue("key-field-name")); } if * (line.hasOption("value-field-name")) { * pageFormSearcher.setValueFieldName(line.getOptionValue("value-field-name")); } */ if (line.hasOption("key-freq")) { pageFormSearcher.loadCache(line.getOptionValue("key-freq"), minFreq); } if (line.hasOption("search")) { logger.debug("searching " + line.getOptionValue("search") + "..."); final FreqSetSearcher.Entry[] result = pageFormSearcher.search(line.getOptionValue("search")); logger.info(Arrays.toString(result)); } if (line.hasOption("interactive-mode")) { pageFormSearcher.interactive(); } } catch (final ParseException e) { // oops, something went wrong if (e.getMessage().length() > 0) { System.out.println("Parsing failed: " + e.getMessage() + "\n"); } final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(400, "java -cp dist/thewikimachine.jar org.fbk.cit.hlt.thewikimachine.index.FormPageSearcher", "\n", options, "\n", true); } }
From source file:fdtutilscli.Main.java
/** * //from w ww . j a va 2s .c o m * @param args the command line arguments */ public static void main(String[] args) { CommandLineParser parser = new PosixParser(); CommandLine line = null; Options options = new Options(); OptionGroup optCommand = new OptionGroup(); OptionGroup optOutput = new OptionGroup(); HelpFormatter formatter = new HelpFormatter(); TRACE trace = TRACE.DEFAULT; optCommand.addOption(OptionBuilder.withArgName("ndf odf nif key seperator").hasArgs(5) .withValueSeparator(' ').withDescription("Description").create("delta")); optCommand.addOption(OptionBuilder.withArgName("dupsfile key seperator").hasArgs(3) .withDescription("Description").create("duplicates")); optCommand.addOption(OptionBuilder.withLongOpt("help").withDescription("print this message.").create("h")); optCommand.addOption( OptionBuilder.withLongOpt("version").withDescription("print version information.").create("V")); optOutput.addOption(new Option("verbose", "be extra verbose")); optOutput.addOption(new Option("quiet", "be extra quiet")); optOutput.addOption(new Option("silent", "same as --quiet")); options.addOptionGroup(optCommand); options.addOptionGroup(optOutput); try { line = parser.parse(options, args); if (line.hasOption("verbose")) { trace = TRACE.VERBOSE; } else if (line.hasOption("quiet") || line.hasOption("silent")) { trace = TRACE.QUIET; } if (line.hasOption("h")) { formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, null, true); return; } else if (line.hasOption("V")) { System.out.println(APP_NAME + " version " + VERSION); System.out.println("fDTDeltaBuilder version " + DTDeltaBuilder.version()); System.out.println("DTDuplicateKeyFinder version " + DTDuplicateKeyFinder.version()); return; } else if (line.hasOption("delta")) { String ndf = line.getOptionValues("delta")[0]; String odf = line.getOptionValues("delta")[1]; String nif = line.getOptionValues("delta")[2]; Integer key = (line.getOptionValues("delta").length <= 3) ? DEFAULT_KEY : new Integer(line.getOptionValues("delta")[3]); String seperator = (line.getOptionValues("delta").length <= 4) ? DEFAULT_SEPERATOR : line.getOptionValues("delta")[4]; doDelta(ndf, odf, nif, key.intValue(), seperator, trace); return; } else if (line.hasOption("duplicates")) { String dupsFile = line.getOptionValues("duplicates")[0]; Integer key = (line.getOptionValues("duplicates").length <= 1) ? DEFAULT_KEY : new Integer(line.getOptionValues("duplicates")[1]); String seperator = (line.getOptionValues("duplicates").length <= 2) ? DEFAULT_SEPERATOR : line.getOptionValues("duplicates")[2]; doDuplicates(dupsFile, key.intValue(), seperator, trace); return; } else if (args.length == 0) { formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, null, true); } else { throw new UnrecognizedOptionException(E_MSG_UNREC_OPT); } } catch (UnrecognizedOptionException e) { formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, HELP_FOOTER + e.getMessage(), true); } catch (ParseException e) { formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, HELP_FOOTER + e.getMessage(), true); } }