public static void main(final String[] args) { Arguments arguments = new Arguments(); try { CmdLineParser parser = new CmdLineParser(arguments); parser.parseArgument(args); } catch (CmdLineException e) { System.out.println("Error: " + e.getLocalizedMessage()); return; } start(arguments); }
public static void main(final String[] args) { Arguments arguments = new Arguments(); try { CmdLineParser parser = new CmdLineParser(arguments); parser.parseArgument(args); } catch (CmdLineException e) { System.out.println("Error: " + e.getLocalizedMessage()); return; } start(arguments); }
private static void processCli (String[] args) { try { // First get the provided parameters if any cli = new CLI(WellKnowns.TOOL_NAME); cli.parseParameters(args); } catch (CmdLineException ex) { logger.warn("Error in command line: {}", ex.getLocalizedMessage(), ex); logger.warn("Exiting ..."); // Stop the JVM, with failure status (1) Runtime.getRuntime().exit(1); } }
public static void main(final String[] args) { Arguments arguments = new Arguments(); try { CmdLineParser parser = new CmdLineParser(arguments); parser.parseArgument(args); } catch (CmdLineException e) { System.out.println("Error: " + e.getLocalizedMessage()); return; } switch (arguments.launcher) { case Arguments.LAUNCHER_AWT: { System.out.println("AWT launcher is starting"); AwtFrameLauncher.start(arguments); break; } case Arguments.LAUNCHER_GL_SURFACE: { System.out.println("GL surface launcher is starting"); GLSurfaceLauncher.start(arguments); break; } default: throw new IllegalStateException("Unknown launcher name: " + arguments.launcher); } }
System.err.println(e.getLocalizedMessage());
System.err.println(e.getLocalizedMessage());
parser.parseArgument(args); } catch (CmdLineException e) { err.printf("Error during command-line parsing: %s%n", e.getLocalizedMessage()); commandLineOptions.help = true;
public static void main(String[] args) throws Exception { CommandLine cmdLine = new CommandLine(); CmdLineParser parser = new CmdLineParser(cmdLine); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getLocalizedMessage()); usage(parser, System.err); System.exit(1); } // Help requested if (cmdLine.needHelp()) { usage(parser, System.out); System.exit(0); } // Configuration file does not exist. if (!new File(cmdLine.getConfigFilename()).isFile()) { System.err.printf("No such file: %s%n", cmdLine.getConfigFilename()); System.exit(1); } File pidFile = new File(cmdLine.getPidFilename()); // Daemonize? if (cmdLine.isDaemon()) { new Daemon().withMainArgs(args).withPidFile(pidFile).daemonize(); } new NewtsService().run(new String[] { "server", cmdLine.getConfigFilename() }); }
public static void main(String[] args) throws Exception { CommandLine cmdLine = new CommandLine(); CmdLineParser parser = new CmdLineParser(cmdLine); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getLocalizedMessage()); usage(parser, System.err); System.exit(1); } // Help requested if (cmdLine.needHelp()) { usage(parser, System.out); System.exit(0); } // Configuration file does not exist. if (!new File(cmdLine.getConfigFilename()).isFile()) { System.err.printf("No such file: %s%n", cmdLine.getConfigFilename()); System.exit(1); } File pidFile = new File(cmdLine.getPidFilename()); // Daemonize? if (cmdLine.isDaemon()) { new Daemon().withMainArgs(args).withPidFile(pidFile).daemonize(); } new NewtsService().run(new String[] { "server", cmdLine.getConfigFilename() }); }
parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getLocalizedMessage()); System.err.println( "java edu.umn.biomedicus.vocabulary.VocabularyInitializer [options...]");
@Test public void testRunError () throws Exception { System.out.println("\n+++ testRunError"); String[] args = new String[]{"-run", "fooBar"}; try { instance.parseParameters(args); fail(); } catch (CmdLineException ex) { System.out.println(ex.getMessage()); System.out.println(ex.getLocalizedMessage()); assertTrue(ex.getMessage().contains("java.lang.ClassNotFoundException")); } }
@Test public void testStepEmpty () throws Exception { System.out.println("\n+++ testStepEmpty"); String[] args = new String[]{"-step"}; try { instance.parseParameters(args); fail(); } catch (CmdLineException ex) { System.out.println(ex.getMessage()); System.out.println(ex.getLocalizedMessage()); assertTrue(ex.getMessage().contains("-step")); } }