This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit 82e42e6e64124bcc4e530ac9c802b99e05d34ff4
Author: Peter Palaga <ppal...@redhat.com>
AuthorDate: Mon May 22 13:41:59 2023 +0200

    Show which options are discriminating in the output of mvnd --help
---
 .../org/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 271836b0..f3c56268 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 class MvndHelpFormatter {
             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 @@ public class MvndHelpFormatter {
         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);
     }
 
     /**

Reply via email to