@Test public void runUnsupportedOption() throws Exception { Application application = new TestApplication(); Assert.assertNotEquals(RUN_STATUS_OK, application.run(new String[]{"search", "query", "-q"})); }
int run(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); if (helpOption) { LOGGER.info(HELP); parser.printUsage(System.out); return 0; } checkArguments(parser); return createAndLaunchCommandManager(); } catch (CmdLineException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(MessageConstants.getMessage(ERROR_PARSE_COMMAND_LINE, Arrays.stream(args) .collect(Collectors.joining(" ")))); LOGGER.info(HELP); parser.printUsage(System.out); exit(1); } catch (ApplicationException | IllegalArgumentException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(e.getMessage()); exit(1); } return 1; }
Application { int run(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); if (helpOption) { LOGGER.info(HELP); parser.printUsage(System.out); return 0; } checkArguments(parser); return createAndLaunchCommandManager(); } catch (CmdLineException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(MessageConstants.getMessage(ERROR_PARSE_COMMAND_LINE, Arrays.stream(args) .collect(Collectors.joining(" ")))); LOGGER.info(HELP); parser.printUsage(System.out); exit(1); } catch (ApplicationException | IllegalArgumentException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(e.getMessage()); exit(1); } return 1; } }
Application { int run(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); if (helpOption) { LOGGER.info(HELP); parser.printUsage(System.out); return 0; } checkArguments(parser); return createAndLaunchCommandManager(); } catch (CmdLineException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(MessageConstants.getMessage(ERROR_PARSE_COMMAND_LINE, Arrays.stream(args) .collect(Collectors.joining(" ")))); LOGGER.info(HELP); parser.printUsage(System.out); exit(1); } catch (ApplicationException | IllegalArgumentException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(e.getMessage()); exit(1); } return 1; } Application(); }
Application { int run(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); if (helpOption) { LOGGER.info(HELP); parser.printUsage(System.out); return 0; } checkArguments(parser); return createAndLaunchCommandManager(); } catch (CmdLineException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(MessageConstants.getMessage(ERROR_PARSE_COMMAND_LINE, Arrays.stream(args) .collect(Collectors.joining(" ")))); LOGGER.info(HELP); parser.printUsage(System.out); exit(1); } catch (ApplicationException | IllegalArgumentException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(e.getMessage()); exit(1); } return 1; } Application(); static void main(String[] args); }
Application { int run(String[] args) { CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(args); if (helpOption) { LOGGER.info(HELP); parser.printUsage(System.out); return 0; } checkArguments(parser); return createAndLaunchCommandManager(); } catch (CmdLineException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(MessageConstants.getMessage(ERROR_PARSE_COMMAND_LINE, Arrays.stream(args) .collect(Collectors.joining(" ")))); LOGGER.info(HELP); parser.printUsage(System.out); exit(1); } catch (ApplicationException | IllegalArgumentException e) { LOGGER.debug(e.getMessage(), e); LOGGER.error(e.getMessage()); exit(1); } return 1; } Application(); static void main(String[] args);  }