Skip to content

Commit

Permalink
[#596] simplify picocli.AutoComplete and improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Jan 9, 2019
1 parent a21f122 commit 82f7c75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/java/picocli/AutoComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ public static void main(String... args) {
if (exitOnError()) { exceptionHandler.andExit(EXIT_CODE_INVALID_INPUT); }

List<Object> result = new CommandLine(new App()).parseWithHandlers(resultHandler, exceptionHandler, args);
int exitCode = result == null || result.isEmpty() ? EXIT_CODE_SUCCESS : (Integer) result.get(0);
if (exitCode == EXIT_CODE_SUCCESS && exitOnSuccess()) {
System.exit(EXIT_CODE_SUCCESS);
} else if (exitOnError()) {
int exitCode = result == null ? EXIT_CODE_SUCCESS : (Integer) result.get(0);
if ((exitCode == EXIT_CODE_SUCCESS && exitOnSuccess()) || (exitCode != EXIT_CODE_SUCCESS && exitOnError())) {
System.exit(exitCode);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/picocli/AutoCompleteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public void testAutoCompleteAppHelp_NoSystemExit() {
{"-h"},
{"--help"},
};
System.setProperty("picocli.autocomplete.systemExitOnSuccess", "false");
for (final String[] args : argsList) {
AutoComplete.main(args);
assertEquals(args[0], AUTO_COMPLETE_APP_USAGE, systemOutRule.getLog());
Expand Down Expand Up @@ -288,6 +289,7 @@ public void checkAssertion() {
assertTrue(actual.contains(AUTO_COMPLETE_APP_USAGE));
}
});
System.setProperty("picocli.autocomplete.systemExitOnSuccess", "false");
System.setProperty("picocli.autocomplete.systemExitOnError", "YES");
AutoComplete.main(TestApp.class.getName());
}
Expand Down

0 comments on commit 82f7c75

Please sign in to comment.