From 2b883c838aabf46a007dcc7a405ba4129179d69d Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Fri, 23 Nov 2018 09:05:24 +0100 Subject: [PATCH] Quell help output on option parsing error This change suppresses help output when option parsing fails, e.g. due to an unrecognized option being specified. This is in keeping with *nix utility idioms; for example, notice what happens when running `git --bogus` or `ls --bogus`: they output an error message, and in some cases a usage message, but they do not print complete help text. This approach is especially important in the case of an application like Bisq, where there are many options and the help text is longer than a typical screen, making it easy to miss the error message altogether, as it is printed at the top of the screen. This change also prints the error message to stderr vs stdout, which is again in keeping with *nix utility idoms. --- core/src/main/java/bisq/core/app/BisqExecutable.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/app/BisqExecutable.java b/core/src/main/java/bisq/core/app/BisqExecutable.java index c2adbe7e2b8..54d45f39bf7 100644 --- a/core/src/main/java/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/bisq/core/app/BisqExecutable.java @@ -100,9 +100,7 @@ public static boolean setupInitialOptionParser(String[] args) throws IOException try { options = parser.parse(args); } catch (OptionException ex) { - System.out.println("error: " + ex.getMessage()); - System.out.println(); - parser.printHelpOn(System.out); + System.err.println("error: " + ex.getMessage()); System.exit(EXIT_FAILURE); return false; } @@ -133,9 +131,7 @@ public void execute(String[] args) throws Exception { return; } } catch (OptionException ex) { - System.out.println("error: " + ex.getMessage()); - System.out.println(); - parser.printHelpOn(System.out); + System.err.println("error: " + ex.getMessage()); System.exit(EXIT_FAILURE); return; }