@Test void testGetCliConfigOption_unknownLongOption() { try { Config.getCliConfigOption("--unknown", "example"); fail("expected parse exception"); } catch (RunnerException e) { assertEquals("Unrecognized option: --unknown. Use -c, --config <arg>", e.getMessage()); } }
static String getCliConfigOption(final String... args) throws RunnerException { final Options cliOptions = new Options(); cliOptions.addOption(CONFIG_FILE_OPTION); CommandLineParser parser = new DefaultParser(); try { val cmd = parser.parse(cliOptions, args); return cmd.getOptionValue("config"); } catch (ParseException e) { val error = String.format("%s. Use -c, --config <arg>", e.getMessage()); throw new RunnerException(error); } }
Config { static String getCliConfigOption(final String... args) throws RunnerException { final Options cliOptions = new Options(); cliOptions.addOption(CONFIG_FILE_OPTION); CommandLineParser parser = new DefaultParser(); try { val cmd = parser.parse(cliOptions, args); return cmd.getOptionValue("config"); } catch (ParseException e) { val error = String.format("%s. Use -c, --config <arg>", e.getMessage()); throw new RunnerException(error); } } }
Config { static String getCliConfigOption(final String... args) throws RunnerException { final Options cliOptions = new Options(); cliOptions.addOption(CONFIG_FILE_OPTION); CommandLineParser parser = new DefaultParser(); try { val cmd = parser.parse(cliOptions, args); return cmd.getOptionValue("config"); } catch (ParseException e) { val error = String.format("%s. Use -c, --config <arg>", e.getMessage()); throw new RunnerException(error); } } private  Config(); }
Config { static String getCliConfigOption(final String... args) throws RunnerException { final Options cliOptions = new Options(); cliOptions.addOption(CONFIG_FILE_OPTION); CommandLineParser parser = new DefaultParser(); try { val cmd = parser.parse(cliOptions, args); return cmd.getOptionValue("config"); } catch (ParseException e) { val error = String.format("%s. Use -c, --config <arg>", e.getMessage()); throw new RunnerException(error); } } private  Config();  }
Config { static String getCliConfigOption(final String... args) throws RunnerException { final Options cliOptions = new Options(); cliOptions.addOption(CONFIG_FILE_OPTION); CommandLineParser parser = new DefaultParser(); try { val cmd = parser.parse(cliOptions, args); return cmd.getOptionValue("config"); } catch (ParseException e) { val error = String.format("%s. Use -c, --config <arg>", e.getMessage()); throw new RunnerException(error); } } private  Config();   }