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

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

commit 139cc882993a524886627a261a4341230ef1e8e4
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Oct 18 20:31:39 2026 +0200

    List the interactive keys in the mvnd help output
    
    Fixes #853
    
    (cherry picked from commit 6173e27e4a6c415d900aa476f6c1b4a437e12af2)
---
 .../org/apache/maven/cli/MvndHelpFormatter.java    | 19 ++++++++++++
 .../apache/maven/cli/MvndHelpFormatterTest.java    | 35 ++++++++++++++++++++++
 2 files changed, 54 insertions(+)

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 95430aaa..313ca56b 100644
--- a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
+++ b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
@@ -40,6 +40,13 @@ public class MvndHelpFormatter {
     private static final Pattern HTML_TAGS_PATTERN = 
Pattern.compile("<[^>]*>");
     private static final Pattern COLUMNS_DETECTOR_PATTERN = 
Pattern.compile("^[ ]+[^s]");
     private static final Pattern WS_PATTERN = Pattern.compile("\\s+");
+    private static final String[][] INTERACTIVE_KEYS = {
+        {"+", "Show more output lines per project in the rolling window."},
+        {"-", "Show fewer output lines per project in the rolling window."},
+        {"Ctrl-B", "Switch between the buffering and no-buffering modes."},
+        {"Ctrl-L", "Redisplay the output."},
+        {"Ctrl-M", "Switch between full-buffering and module-buffering (Enter 
works too)."}
+    };
 
     static String toPlainText(String javadocText) {
         return HTML_TAGS_PATTERN.matcher(javadocText).replaceAll("");
@@ -145,6 +152,18 @@ public class MvndHelpFormatter {
             wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, 
lineEnd, indent);
         });
 
+        help.append(lineSeparator).append(lineSeparator).append("mvnd 
interactive keys:");
+
+        for (String[] key : INTERACTIVE_KEYS) {
+            help.append(lineSeparator);
+            int indentPos = help.length() + indent.length();
+            int lineEnd = help.length() + terminalWidth;
+            spaces(help, HelpFormatter.DEFAULT_LEFT_PAD);
+            help.append(key[0]);
+            spaces(help, indentPos - help.length());
+            wrap(help, key[1], terminalWidth, lineEnd, indent);
+        }
+
         return help.toString();
     }
 
diff --git 
a/daemon/src/test/java/org/apache/maven/cli/MvndHelpFormatterTest.java 
b/daemon/src/test/java/org/apache/maven/cli/MvndHelpFormatterTest.java
new file mode 100644
index 00000000..1050e8bc
--- /dev/null
+++ b/daemon/src/test/java/org/apache/maven/cli/MvndHelpFormatterTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cli;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class MvndHelpFormatterTest {
+
+    @Test
+    void helpListsInteractiveKeys() {
+        String help = MvndHelpFormatter.displayHelp(new CLIManager());
+        assertTrue(help.contains("mvnd interactive keys:"), help);
+        for (String key : new String[] {"Ctrl-B", "Ctrl-L", "Ctrl-M"}) {
+            assertTrue(help.contains(key), key);
+        }
+    }
+}

Reply via email to