From ffa10fb2e4a4cce93a04cbaea0272d4de07190c9 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Mon, 22 May 2023 13:41:59 +0200 Subject: [PATCH] Show which options are discriminating in the output of mvnd --help --- .../apache/maven/cli/MvndHelpFormatter.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java index 271836b00..976e8c9f0 100644 --- a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java +++ b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java @@ -121,8 +121,15 @@ public static String displayHelp(CLIManager cliManager) { spaces(help, indentPos - help.length()); wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent); - indentedLine(help, terminalWidth, "Default", env.getDefault(), indent); - indentedLine(help, terminalWidth, "Env. variable", env.getEnvironmentVariable(), indent); + if (env.isDiscriminating()) { + indentedLine(help, terminalWidth, "This is a discriminating start parameter.", indent); + } + if (env.getDefault() != null) { + indentedLine(help, terminalWidth, "Default: " + env.getDefault(), indent); + } + if (env.getEnvironmentVariable() != null) { + indentedLine(help, terminalWidth, "Env. variable:" + env.getEnvironmentVariable(), indent); + } }); help.append(lineSeparator).append(lineSeparator).append("mvnd value types:"); @@ -151,14 +158,10 @@ private static int getTerminalWidth() { return terminalWidth; } - private static void indentedLine( - StringBuilder stringBuilder, int terminalWidth, String key, String value, String indent) { - int lineEnd; - if (value != null) { - lineEnd = stringBuilder.length() + terminalWidth; - stringBuilder.append(System.lineSeparator()).append(indent); - wrap(stringBuilder, key + ": " + value, terminalWidth, lineEnd, indent); - } + private static void indentedLine(StringBuilder stringBuilder, int terminalWidth, String text, String indent) { + final int lineEnd = stringBuilder.length() + terminalWidth; + stringBuilder.append(System.lineSeparator()).append(indent); + wrap(stringBuilder, text, terminalWidth, lineEnd, indent); } /**