Main { CommandLine parseOption(String[] arguments) { CommandLineParser commandLineParser = new DefaultParser(); try { return commandLineParser.parse(getOptions(), arguments); } catch (ParseException parseException) { System.err.println("Parsing failed. Reason: " + parseException.getMessage()); } return null; }  static void main(String[] args);  }
@Test public void testOption() { Main main = new Main(); CommandLine command = main.parseOption(new String[] { "light.sh", "-a1234", "-p" }); assertThat(command.hasOption("a"), is(true)); assertThat(command.hasOption("attach"), is(true)); assertThat(command.getOptionValue("a"), is("1234")); assertThat(command.getOptionValue("attach"), is("1234")); }