List of usage examples for org.apache.commons.cli HelpFormatter printHelp
public void printHelp(String cmdLineSyntax, Options options, boolean autoUsage)
options
with the specified command line syntax. From source file:com.act.lcms.db.io.LoadPlateCompositionIntoDB.java
public static void main(String[] args) throws Exception { Options opts = new Options(); opts.addOption(Option.builder("t").argName("type") .desc("The type of plate composition in this file, valid options are: " + StringUtils.join(Arrays.asList(Plate.CONTENT_TYPE.values()), ", ")) .hasArg().longOpt("plate-type").required().build()); opts.addOption(Option.builder("i").argName("path").desc("The plate composition file to read").hasArg() .longOpt("input-file").required().build()); // DB connection options. opts.addOption(Option.builder().argName("database url") .desc("The url to use when connecting to the LCMS db").hasArg().longOpt("db-url").build()); opts.addOption(Option.builder("u").argName("database user").desc("The LCMS DB user").hasArg() .longOpt("db-user").build()); opts.addOption(Option.builder("p").argName("database password").desc("The LCMS DB password").hasArg() .longOpt("db-pass").build()); opts.addOption(Option.builder("H").argName("database host") .desc(String.format("The LCMS DB host (default = %s)", DB.DEFAULT_HOST)).hasArg().longOpt("db-host") .build());/*from www .j a v a 2s . c o m*/ opts.addOption(Option.builder("P").argName("database port") .desc(String.format("The LCMS DB port (default = %d)", DB.DEFAULT_PORT)).hasArg().longOpt("db-port") .build()); opts.addOption(Option.builder("N").argName("database name") .desc(String.format("The LCMS DB name (default = %s)", DB.DEFAULT_DB_NAME)).hasArg() .longOpt("db-name").build()); // Everybody needs a little help from their friends. opts.addOption( Option.builder("h").argName("help").desc("Prints this help message").longOpt("help").build()); CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HelpFormatter fmt = new HelpFormatter(); fmt.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), opts, true); System.exit(1); } if (cl.hasOption("help")) { new HelpFormatter().printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), opts, true); return; } File inputFile = new File(cl.getOptionValue("input-file")); if (!inputFile.exists()) { System.err.format("Unable to find input file at %s\n", cl.getOptionValue("input-file")); new HelpFormatter().printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), opts, true); System.exit(1); } PlateCompositionParser parser = new PlateCompositionParser(); parser.processFile(inputFile); Plate.CONTENT_TYPE contentType = null; try { contentType = Plate.CONTENT_TYPE.valueOf(cl.getOptionValue("plate-type")); } catch (IllegalArgumentException e) { System.err.format("Unrecognized plate type '%s'\n", cl.getOptionValue("plate-type")); new HelpFormatter().printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), opts, true); System.exit(1); } DB db; if (cl.hasOption("db-url")) { db = new DB().connectToDB(cl.getOptionValue("db-url")); } else { Integer port = null; if (cl.getOptionValue("P") != null) { port = Integer.parseInt(cl.getOptionValue("P")); } db = new DB().connectToDB(cl.getOptionValue("H"), port, cl.getOptionValue("N"), cl.getOptionValue("u"), cl.getOptionValue("p")); } try { db.getConn().setAutoCommit(false); Plate p = Plate.getOrInsertFromPlateComposition(db, parser, contentType); switch (contentType) { case LCMS: List<LCMSWell> LCMSWells = LCMSWell.getInstance().insertFromPlateComposition(db, parser, p); for (LCMSWell LCMSWell : LCMSWells) { System.out.format("%d: %d x %d %s %s\n", LCMSWell.getId(), LCMSWell.getPlateColumn(), LCMSWell.getPlateRow(), LCMSWell.getMsid(), LCMSWell.getComposition()); } break; case STANDARD: List<StandardWell> standardWells = StandardWell.getInstance().insertFromPlateComposition(db, parser, p); for (StandardWell standardWell : standardWells) { System.out.format("%d: %d x %d %s\n", standardWell.getId(), standardWell.getPlateColumn(), standardWell.getPlateRow(), standardWell.getChemical()); } break; case DELIVERED_STRAIN: List<DeliveredStrainWell> deliveredStrainWells = DeliveredStrainWell.getInstance() .insertFromPlateComposition(db, parser, p); for (DeliveredStrainWell deliveredStrainWell : deliveredStrainWells) { System.out.format("%d: %d x %d (%s) %s %s \n", deliveredStrainWell.getId(), deliveredStrainWell.getPlateColumn(), deliveredStrainWell.getPlateRow(), deliveredStrainWell.getWell(), deliveredStrainWell.getMsid(), deliveredStrainWell.getComposition()); } break; case INDUCTION: List<InductionWell> inductionWells = InductionWell.getInstance().insertFromPlateComposition(db, parser, p); for (InductionWell inductionWell : inductionWells) { System.out.format("%d: %d x %d %s %s %s %d\n", inductionWell.getId(), inductionWell.getPlateColumn(), inductionWell.getPlateRow(), inductionWell.getMsid(), inductionWell.getComposition(), inductionWell.getChemical(), inductionWell.getGrowth()); } break; case PREGROWTH: List<PregrowthWell> pregrowthWells = PregrowthWell.getInstance().insertFromPlateComposition(db, parser, p); for (PregrowthWell pregrowthWell : pregrowthWells) { System.out.format("%d: %d x %d (%s @ %s) %s %s %d\n", pregrowthWell.getId(), pregrowthWell.getPlateColumn(), pregrowthWell.getPlateRow(), pregrowthWell.getSourcePlate(), pregrowthWell.getSourceWell(), pregrowthWell.getMsid(), pregrowthWell.getComposition(), pregrowthWell.getGrowth()); } break; case FEEDING_LCMS: List<FeedingLCMSWell> feedingLCMSWells = FeedingLCMSWell.getInstance() .insertFromPlateComposition(db, parser, p); for (FeedingLCMSWell feedingLCMSWell : feedingLCMSWells) { System.out.format("%d: %d x %d (%s @ %s) %s %s %f\n", feedingLCMSWell.getId(), feedingLCMSWell.getPlateColumn(), feedingLCMSWell.getPlateRow(), feedingLCMSWell.getMsid(), feedingLCMSWell.getComposition(), feedingLCMSWell.getExtract(), feedingLCMSWell.getChemical(), feedingLCMSWell.getConcentration()); } break; default: System.err.format("Unrecognized/unimplemented data type '%s'\n", contentType); break; } // If we didn't encounter an exception, commit the transaction. db.getConn().commit(); } catch (Exception e) { System.err.format("Caught exception when trying to load plate composition, rolling back. %s\n", e.getMessage()); db.getConn().rollback(); throw (e); } finally { db.getConn().close(); } }
From source file:ar.com.ergio.uncoma.cei.MiniPas.java
/** * @param args/* w w w. j a v a 2 s. c o m*/ * @throws IOException */ @SuppressWarnings("static-access") public static void main(String[] args) throws IOException { // Config logging system -- TODO improve this Handler console = new ConsoleHandler(); ROOT_LOG.addHandler(console); // Create cmdline options - TODO - I18N final Options options = new Options(); options.addOption(new Option("help", "Muestra este mensaje")); options.addOption(new Option("version", "Muestra la informaci\u00f3 de versi\u00f3n y termina")); options.addOption(new Option("debug", "Muestra informaci\u00f3n para depuraci\u00f3n")); options.addOption( OptionBuilder.withArgName("file").hasArg().withDescription("Archivo de log").create("logFile")); final CommandLineParser cmdlineParser = new GnuParser(); final HelpFormatter formatter = new HelpFormatter(); try { final CommandLine cmdline = cmdlineParser.parse(options, args); // Process command line args -- TODO Improve this if (args.length == 0 || cmdline.hasOption("help")) { formatter.printHelp("minipas", options, true); } else if (cmdline.hasOption("version")) { System.out.println("MiniPas versi\u00f3n: 0.0.1"); } else if (cmdline.hasOption("debug")) { ROOT_LOG.setLevel(Level.FINE); } else { ROOT_LOG.fine("Arguments: " + Arrays.toString(args)); final Scanner scanner = new Scanner(args[0]); while (scanner.hasTokens()) { System.out.println(scanner.nextToken()); } } } catch (ParseException e) { formatter.printHelp("minipas", options, true); } }
From source file:eu.freme.bpt.Main.java
public static void main(String[] args) { final List<String> services = new ArrayList<>(); for (EService eService : EService.values()) { services.add(eService.getName()); }/* w w w .j a v a 2 s . c om*/ Pair<EService, String[]> serviceAndArgs = extractService(args, services); EService service = serviceAndArgs.getName(); // create options that will be parsed from the args /////// General BPT options /////// Option helpOption = new Option("h", "help", false, "Prints this message"); Option inputOption = Option.builder("if").longOpt("input-file").argName("input file").desc( "The input file or directory to process. In case of a directory, each file in that directory is processed. " + "If not given, standard in is used.") .hasArg().build(); Option outputOption = Option.builder("od").longOpt("output-dir").argName("output dir") .desc("The output directory. If not given, output is written to standard out.").hasArg().build(); Option propertiesOption = Option.builder("prop").longOpt("properties").argName("properties file") .desc("The properties file that contains configuration of the tool.").hasArg().build(); Options options = new Options().addOption(helpOption).addOption(inputOption).addOption(outputOption) .addOption(propertiesOption); /////// Common service options /////// Option informatOption = Option.builder("f").longOpt("informat").argName("FORMAT") .desc("The format of the input document(s). Defaults to 'turtle'").hasArg().build(); Option outformatOption = Option.builder("o").longOpt("outformat").argName("FORMAT") .desc("The desired output format of the service. Defaults to 'turtle'").hasArg().build(); options.addOption(informatOption).addOption(outformatOption); /////// Service specific options /////// if (service != null) { switch (service) { case E_TRANSLATION: ETranslation.addOptions(options); break; case E_ENTITY: EEntity.addOptions(options); break; case E_LINK: ELink.addOptions(options); break; case E_TERMINOLOGY: ETerminology.addOptions(options); break; case PIPELINING: Pipelining.addOptions(options); break; case E_PUBLISHING: // TODO ! default: logger.warn("Unknown service {}. Skipping!", service); break; } } else { ETranslation.addOptions(options); EEntity.addOptions(options); ELink.addOptions(options); ETerminology.addOptions(options); Pipelining.addOptions(options); } CommandLine commandLine = null; int exitValue; try { CommandLineParser parser = new DefaultParser(); commandLine = parser.parse(options, serviceAndArgs.getValue()); exitValue = 0; } catch (ParseException e) { System.err.println(e.getMessage()); exitValue = 1; } if ((exitValue != 0) || commandLine.hasOption("h") || service == null) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(132); formatter.printHelp("java -jar <this jar file> <e-service> ", options, true); System.exit(exitValue); } logger.debug("Commandline successfully parsed!"); try { BPT batchProcessingTool = new BPT(); if (commandLine.hasOption("prop")) { batchProcessingTool.loadProperties(commandLine.getOptionValue("prop")); } if (commandLine.hasOption("if")) { batchProcessingTool.setInput(commandLine.getOptionValue("if")); } if (commandLine.hasOption("od")) { batchProcessingTool.setOutput(commandLine.getOptionValue("od")); } if (commandLine.hasOption('f')) { batchProcessingTool.setInFormat(Format.valueOf(commandLine.getOptionValue('f').replace('-', '_'))); } if (commandLine.hasOption('o')) { batchProcessingTool.setOutFormat(Format.valueOf(commandLine.getOptionValue('o').replace('-', '_'))); } switch (service) { case E_TRANSLATION: batchProcessingTool.eTranslation(commandLine.getOptionValue("source-lang"), commandLine.getOptionValue("target-lang"), commandLine.getOptionValue("system"), commandLine.getOptionValue("domain"), commandLine.getOptionValue("key")); break; case E_ENTITY: batchProcessingTool.eEntity(commandLine.getOptionValue("language"), commandLine.getOptionValue("dataset"), commandLine.getOptionValue("mode")); break; case E_LINK: batchProcessingTool.eLink(commandLine.getOptionValue("templateid")); break; case E_TERMINOLOGY: batchProcessingTool.eTerminology(commandLine.getOptionValue("source-lang"), commandLine.getOptionValue("target-lang"), commandLine.getOptionValue("collection"), commandLine.getOptionValue("domain"), commandLine.getOptionValue("key"), commandLine.getOptionValue("mode")); break; case PIPELINING: batchProcessingTool.pipelining(commandLine.getOptionValue("templateid")); break; case E_PUBLISHING: default: logger.error("Unknown service {}. Aborting!", service); System.exit(3); } } catch (Exception e) { logger.error("Cannot handle input or output. Reason: ", e); System.exit(2); } }
From source file:com.chigix.autosftp.Application.java
public static void main(String[] args) { Options options = new Options(); options.addOption(Option.builder("P").longOpt("port").hasArg().build()) .addOption(Option.builder("h").longOpt("help").desc("Print this message").build()) .addOption(Option.builder("i").argName("identity_file").hasArg().build()); int port = 22; CommandLine line;/*from w w w . j av a2 s .c om*/ try { line = new DefaultParser().parse(options, args); } catch (UnrecognizedOptionException ex) { System.err.println(ex.getMessage()); return; } catch (ParseException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); return; } if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("autosftp /path/to/watch [user@]host2:[file2]", options, true); return; } String givenPort; if (line.hasOption("port") && StringUtils.isNumeric(givenPort = line.getOptionValue("port"))) { port = Integer.valueOf(givenPort); } if (line.getArgs().length < 0) { System.err.println("Please provide a path to watch."); return; } localPath = Paths.get(line.getArgs()[0]); if (line.getArgs().length < 1) { System.err.println("Please provide remote ssh information."); return; } SshAddressParser addressParse; try { addressParse = new SshAddressParser().parse(line.getArgs()[1]); } catch (SshAddressParser.InvalidAddressException ex) { System.err.println(ex.getMessage()); return; } if (addressParse.getDefaultDirectory() != null) { remotePath = Paths.get(addressParse.getDefaultDirectory()); } try { sshSession = new JSch().getSession(addressParse.getUsername(), addressParse.getHost(), port); } catch (JSchException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); return; } try { sshOpen(); } catch (JSchException ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); sshClose(); } System.out.println("Remote Default Path: " + remotePath); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { sshClose(); System.out.println("Bye~~~"); } }); try { watchDir(Paths.get(line.getArgs()[0])); } catch (Exception ex) { Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.cws.esolutions.security.main.UserManagementUtility.java
public static final void main(final String[] args) { final String methodName = UserManagementUtility.CNAME + "#main(final String[] args)"; if (DEBUG) {// ww w. ja va 2 s . c o m DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", (Object) args); } if (args.length == 0) { HelpFormatter usage = new HelpFormatter(); usage.printHelp(UserManagementUtility.CNAME, options, true); return; } try { CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(options, args); if (DEBUG) { DEBUGGER.debug("CommandLineParser parser: {}", parser); DEBUGGER.debug("CommandLine commandLine: {}", commandLine); DEBUGGER.debug("CommandLine commandLine.getOptions(): {}", (Object[]) commandLine.getOptions()); DEBUGGER.debug("CommandLine commandLine.getArgList(): {}", commandLine.getArgList()); } if ((commandLine.hasOption("configFile")) && (!(StringUtils.isBlank(commandLine.getOptionValue("configFile"))))) { SecurityServiceInitializer.initializeService(commandLine.getOptionValue("configFile"), UserManagementUtility.LOG_CONFIG, true); } else { SecurityServiceInitializer.initializeService(UserManagementUtility.SEC_CONFIG, UserManagementUtility.LOG_CONFIG, true); } AccountControlResponse response = null; final UserAccount userAccount = new UserAccount(); final RequestHostInfo reqInfo = new RequestHostInfo(); final SecurityConfigurationData secConfigData = UserManagementUtility.svcBean.getConfigData(); final SecurityConfig secConfig = secConfigData.getSecurityConfig(); try { reqInfo.setHostAddress(InetAddress.getLocalHost().getHostAddress()); reqInfo.setHostName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException uhx) { reqInfo.setHostAddress("127.0.0.1"); reqInfo.setHostName("localhost"); } if (DEBUG) { DEBUGGER.debug("SecurityConfigurationData secConfig: {}", secConfigData); DEBUGGER.debug("SecurityConfig secConfig: {}", secConfig); DEBUGGER.debug("RequestHostInfo reqInfo: {}", reqInfo); } AccountControlRequest request = new AccountControlRequest(); request.setApplicationId(secConfig.getApplicationId()); request.setApplicationName(secConfig.getApplicationName()); request.setHostInfo(reqInfo); request.setRequestor(secConfig.getSvcAccount()); if (DEBUG) { DEBUGGER.debug("AccountControlRequest request: {}", request); } if (commandLine.hasOption("search")) { if (StringUtils.isEmpty(commandLine.getOptionValue("search"))) { throw new ParseException("No entry option was provided. Cannot continue."); } userAccount.setEmailAddr(commandLine.getOptionValue("search")); if (DEBUG) { DEBUGGER.debug("UserAccount userAccount: {}", userAccount); } request.setUserAccount(userAccount); if (DEBUG) { DEBUGGER.debug("AccountControlRequest: {}", request); } response = processor.searchAccounts(request); } else if (commandLine.hasOption("load")) { if (StringUtils.isEmpty(commandLine.getOptionValue("load"))) { throw new ParseException("No entry option was provided. Cannot continue."); } userAccount.setGuid(commandLine.getOptionValue("load")); request.setUserAccount(userAccount); if (DEBUG) { DEBUGGER.debug("AccountControlRequest: {}", request); } response = processor.loadUserAccount(request); } if (DEBUG) { DEBUGGER.debug("AccountControlResponse response: {}", response); } if ((response != null) && (response.getRequestStatus() == SecurityRequestStatus.SUCCESS)) { UserAccount account = response.getUserAccount(); if (DEBUG) { DEBUGGER.debug("UserAccount: {}", account); } System.out.println(account); } } catch (ParseException px) { ERROR_RECORDER.error(px.getMessage(), px); System.err.println("An error occurred during processing: " + px.getMessage()); } catch (SecurityException sx) { ERROR_RECORDER.error(sx.getMessage(), sx); System.err.println("An error occurred during processing: " + sx.getMessage()); } catch (SecurityServiceException ssx) { ERROR_RECORDER.error(ssx.getMessage(), ssx); System.err.println("An error occurred during processing: " + ssx.getMessage()); } }
From source file:com.asakusafw.compiler.bootstrap.AllBatchCompilerDriver.java
/** * The program entry./* w w w . jav a 2 s . c om*/ * @param args command line arguments */ public static void main(String... args) { try { if (start(args) == false) { System.exit(1); } } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp(MessageFormat.format("java -classpath ... {0}", //$NON-NLS-1$ AllBatchCompilerDriver.class.getName()), OPTIONS, true); e.printStackTrace(System.out); System.exit(1); } }
From source file:com.asakusafw.dmdl.thundergate.Main.java
/** * ???//from w w w . j a v a2 s.com * @param args ??????????? */ public static void main(String... args) { GenerateTask task; try { Configuration conf = loadConfigurationFromArguments(args); task = new GenerateTask(conf); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp(MessageFormat.format("java -classpath ... {0}", Main.class.getName()), OPTIONS, true); e.printStackTrace(System.out); System.exit(1); return; } try { task.call(); } catch (Exception e) { e.printStackTrace(System.out); System.exit(1); return; } }
From source file:com.cloudera.learnavro.test.GenerateTestAvro.java
/** *///w w w . jav a 2 s. co m public static void main(String argv[]) throws IOException, InstantiationException { CommandLine cmd = null; Options options = new Options(); options.addOption("?", false, "Help for command-line"); options.addOption("n", true, "# tuples to emit per file"); try { CommandLineParser parser = new PosixParser(); cmd = parser.parse(options, argv); } catch (ParseException pe) { HelpFormatter fmt = new HelpFormatter(); fmt.printHelp("GenerateTestAvro", options, true); System.exit(-1); } if (cmd.hasOption("?")) { HelpFormatter fmt = new HelpFormatter(); fmt.printHelp("GenerateTestAvro", options, true); System.exit(0); } int numToEmit = 100; if (cmd.hasOption("n")) { try { numToEmit = Integer.parseInt(cmd.getOptionValue("n")); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } } String[] argArray = cmd.getArgs(); if (argArray.length == 0) { HelpFormatter fmt = new HelpFormatter(); fmt.printHelp("GenerateTestAvro", options, true); System.exit(0); } File outputDir = new File(argArray[0]).getCanonicalFile(); GenerateTestAvro gta = new GenerateTestAvro(); gta.generateData(outputDir, numToEmit); }
From source file:cloud.elasticity.elastman.App.java
/** * The entry point to the ElastMan main program. * // w w w. j a v a 2s . c o m * @param args The first argument is the mode which can be inter, ident, or control * corresponding to interactive mode, system identification mode, or control mode. * The second argument is the configuration file * The third argument is password password */ public static void main(String[] args) { // 1) parse the command line // For more information http://commons.apache.org/cli/ Options options = new Options(); options.addOption("i", "ident", false, "Enter system identification mode."); options.addOption("c", "control", false, "Enter controller mode."); options.addOption("o", "options", true, "Configuration file. Default elastman.conf"); options.addOption("u", "username", true, "Username in the form Tenant:UserName"); options.addOption("p", "password", true, "User password"); options.addOption("k", "keyname", true, "Name of SSH key to use"); options.addOption("z", "zone", true, "The OpenStack availability zone such as the default RegionOne"); options.addOption("e", "endpoint", true, "The URL to access OpenStack API such as http://192.168.1.1:5000/v2.0/"); options.addOption("s", "syncserver", true, "The URL access the WebSyncServer"); options.addOption("h", "help", false, "Print this help"); CommandLineParser parser = new GnuParser(); try { cmd = parser.parse(options, args); } catch (ParseException e2) { System.out.println(e2.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ElastMan", options, true); System.exit(1); } // if h then show help and exit if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ElastMan", options, true); System.exit(0); } // 2) Try to load the properties file. // Command line arguments override settings in the properties file // If no properties file exists. defaults will be used String filename = "control.prop"; // the default file name if (cmd.hasOption("o")) { filename = cmd.getOptionValue("o"); } Props.load(filename, cmd); // Props.save(filename); // System.exit(-1); // 3) If no password in command line nor in config file then ask the user if (Props.password == null) { Console cons; char[] passwd; if ((cons = System.console()) != null && // more secure and without echo! (passwd = cons.readPassword("[%s]", "Password:")) != null) { Props.password = new String(passwd); } else { // if you don't have a console! E.g., Running in eclipse System.out.print("Password: "); Props.password = scanner.nextLine(); } } // 4) Start the UI App app = new App(); app.textUI(args); }
From source file:edu.jhu.hlt.parma.inference.transducers.StringEditModelTrainer.java
public static void main(String[] args) { final String usage = "java " + StringEditModelTrainer.class.getName() + " [OPTIONS]"; final CommandLineParser parser = new PosixParser(); final Options options = createOptions(); CommandLine cmd = null;// ww w. j ava2s . c om final HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e1) { System.err.println(e1.getMessage()); formatter.printHelp(usage, options, true); System.exit(-1); } final StringEditModelTrainer trainer = new StringEditModelTrainer(); final boolean success = trainer.execute(cmd); if (!success) { formatter.printHelp(usage, options, true); System.exit(-1); } }