Main { public void run(String[] args) throws ClientException { try { List<String> remainingArgs = readActionAndOptions(args); switch (action) { case UPLOAD: doUpload(remainingArgs); break; case DELETE: doDelete(remainingArgs); break; case FIND: doFind(remainingArgs); break; case FIND_AND_DELETE: doDelete(remainingArgs); break; case LISTALL: doListAll(remainingArgs); break; case HELP: showHelp(remainingArgs); break; default: showHelp(remainingArgs); break; } } catch (ClientException e) { if (e.getHelpDisplay() == HelpDisplay.SHOW_HELP) { new Help(output).printMessageAndGlobalUsage(e.getMessage()); } else { output.println(e.getMessage()); } throw e; } } Main(InputStream in, PrintStream out); static void main(String[] args); void run(String[] args); static String getInvokedName();  }
@Test public void testRun() throws ClientException { MainRunner runner = new MainRunner("No options were given", 47); runner.run(); assertThat(runner.stdout, containsString("Usage: java -jar larsClient.jar action [options] [arguments]")); }
@Test public void shouldPrintHelpMessageIfHelpOptionSpecified() throws ClientException { MainRunner runner = new MainRunner(null, 45); runner.run("--help"); assertThat(runner.stdout, containsString("Usage: java -jar larsClient.jar action [options] [arguments] ...")); assertThat(runner.stdout, containsString("Show help for larsClient.")); assertThat(runner.stdout, containsString("Upload ESAs to the repository.")); assertThat(runner.stdout, containsString("Delete one or more assets from the repository, specified by id.")); assertThat(runner.stdout, containsString("List all the assets currently in the repository")); }
@Test public void shouldPrintHelpMessageIfHelpInvokedOnNonExistentComment() throws ClientException { MainRunner runner = new MainRunner(null, 45); runner.run("--help", "cheese"); }
@Test public void shouldPrintHelpForHelp() throws ClientException { MainRunner runner = new MainRunner(null, 27); runner.run("--help", "help"); assertThat(runner.stdout, containsString("Show help for larsClient.")); }
@Test public void shouldPrintHelpForUpload() throws ClientException { MainRunner runner = new MainRunner(null, 31); runner.run("--help", "upload"); assertThat(runner.stdout, containsString("Uploads one or more features to a LARS server.")); }
@Test public void shouldPrintHelpForDelete() throws ClientException { MainRunner runner = new MainRunner(null, 27); runner.run("--help", "delete"); assertThat(runner.stdout, containsString("Delete one or more assets from the repository, specified by id.")); }
@Test public void shouldPrintHelpForFindAndDelete() throws ClientException { MainRunner runner = new MainRunner(null, 30); runner.run("--help", "findAndDelete"); assertThat(runner.stdout, containsString("Finds and deletes all the assets in the repository")); }
@Test public void shouldPrintHelpForListAll() throws ClientException { MainRunner runner = new MainRunner(null, 27); runner.run("--help", "listAll"); assertThat(runner.stdout, containsString("List all the assets currently in the repository")); }