@Test void getCliConfigOption_validLongOption() { try { String option = Config.getCliConfigOption("--config", "example"); assertEquals("example", option); } catch (RunnerException e) { fail(); } }
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();   }