List of usage examples for org.apache.commons.cli MissingArgumentException toString
public String toString()
From source file:org.lsc.Launcher.java
/** * Manage command line options./*from w w w . j a v a 2s . c o m*/ * @param args command line * @return the status code (0: OK, >=1 : failed) */ private int parseOptions(final String[] args) { CommandLineParser parser = new GnuParser(); try { cmdLine = parser.parse(options, args); if (cmdLine.hasOption("a")) { asyncType = parseSyncType(cmdLine.getOptionValue("a")); } if (cmdLine.hasOption("s")) { syncType = parseSyncType(cmdLine.getOptionValue("s")); } if (cmdLine.hasOption("f")) { configurationLocation = new File(cmdLine.getOptionValue("f")).getAbsolutePath(); } if (cmdLine.hasOption("t")) { threads = Integer.parseInt(cmdLine.getOptionValue("t")); } if (cmdLine.hasOption("i")) { timeLimit = Integer.parseInt(cmdLine.getOptionValue("i")); } if (cmdLine.hasOption("c")) { cleanType = parseSyncType(cmdLine.getOptionValue("c")); } if (cmdLine.hasOption("x")) { convertConfiguration = true; } if (cmdLine.hasOption("v")) { validateConfiguration = true; } if (cmdLine.getOptions().length == 0 || cmdLine.hasOption("h") || ((asyncType.size() == 0) && (syncType.size() == 0) && (cleanType.size() == 0)) && !convertConfiguration && !validateConfiguration) { printHelp(); return 1; } if (!asyncType.isEmpty() && (!syncType.isEmpty() || !cleanType.isEmpty())) { System.err.println( "Asynchronous synchronization is mutually exclusive with synchronous synchronizing and cleaning !"); printHelp(); return 1; } } catch (MissingArgumentException e) { LOGGER.error("Missing arguments ({})", e.toString()); LOGGER.debug(e.toString(), e); return 1; } catch (ParseException e) { LOGGER.error("Unable to parse the options ({})", e.toString()); LOGGER.debug(e.toString(), e); return 1; } return 0; }