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

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


The following commit(s) were added to refs/heads/master by this push:
     new d62ecadb35 [MNG-8348] Fix typos in deprecation warning message (#1844)
d62ecadb35 is described below

commit d62ecadb35dd4b9a39d9c219bfb53b032657e0f1
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Thu Oct 24 13:51:57 2024 +0200

    [MNG-8348] Fix typos in deprecation warning message (#1844)
---
 .../apache/maven/cling/invoker/CommonsCliOptions.java  | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git 
a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java 
b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java
index 471757ca4f..04ad3ebbd9 100644
--- 
a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java
+++ 
b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java
@@ -219,16 +219,22 @@ public abstract class CommonsCliOptions implements 
Options {
         printWriter.accept("Detected deprecated option use in " + source);
         for (Option option : cliManager.getUsedDeprecatedOptions()) {
             StringBuilder sb = new StringBuilder();
-            sb.append("The option -").append(option.getOpt());
+            sb.append("The option ");
+            if (option.getOpt() != null) {
+                sb.append("-").append(option.getOpt());
+            }
             if (option.getLongOpt() != null) {
-                sb.append(",--").append(option.getLongOpt());
+                if (option.getOpt() != null) {
+                    sb.append(",");
+                }
+                sb.append("--").append(option.getLongOpt());
             }
             sb.append(" is deprecated ");
             if (option.getDeprecated().isForRemoval()) {
                 sb.append("and will be removed in a future version");
             }
             if (option.getDeprecated().getSince() != null) {
-                sb.append("since ")
+                sb.append(" since ")
                         .append(request.commandName())
                         .append(" ")
                         .append(option.getDeprecated().getSince());
@@ -415,7 +421,7 @@ public abstract class CommonsCliOptions implements Options {
             // We need to eat any quotes surrounding arguments...
             String[] cleanArgs = CleanArgument.cleanArgs(args);
             DefaultParser parser = DefaultParser.builder()
-                    .setDeprecatedHandler(usedDeprecatedOptions::add)
+                    .setDeprecatedHandler(this::addDeprecatedOption)
                     .build();
             CommandLine commandLine = parser.parse(options, cleanArgs);
             // to trigger deprecation handler, so we can report deprecation 
BEFORE we actually use options
@@ -423,6 +429,10 @@ public abstract class CommonsCliOptions implements Options 
{
             return commandLine;
         }
 
+        protected void addDeprecatedOption(Option option) {
+            usedDeprecatedOptions.add(option);
+        }
+
         public org.apache.commons.cli.Options getOptions() {
             return options;
         }

Reply via email to