Skip to content

Commit 6d88a84

Browse files
fix help default text (#11099) (#11175)
Include --infer alongside --model and --plugins in help footer. Align CLI help with runtime defaults. (cherry picked from commit 3a3b935) Co-authored-by: Arturo Bernal <abernal@apache.org>
1 parent 267a207 commit 6d88a84

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/CommonsCliUpgradeOptions.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void displayHelp(ParserRequest request, Consumer<String> printStream) {
126126
printStream.accept(
127127
" -a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
128128
printStream.accept("");
129-
printStream.accept("Default behavior: --model and --plugins are applied if no other options are specified");
129+
printStream.accept("Default behavior: --model --plugins --infer are applied if no other options are specified");
130130
printStream.accept("");
131131
}
132132

‎impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/PluginUpgradeCliTest.java‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
*/
1919
package org.apache.maven.cling.invoker.mvnup;
2020

21+
import java.io.ByteArrayOutputStream;
22+
import java.nio.charset.StandardCharsets;
23+
2124
import org.apache.commons.cli.ParseException;
2225
import org.apache.maven.api.cli.mvnup.UpgradeOptions;
26+
import org.apache.maven.cling.MavenUpCling;
27+
import org.codehaus.plexus.classworlds.ClassWorld;
2328
import org.junit.jupiter.api.Test;
2429

2530
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -190,4 +195,25 @@ void testInterpolationWithPluginsOption() throws ParseException {
190195
assertTrue(interpolated.plugins().isPresent(), "Interpolated options should preserve --plugins");
191196
assertTrue(interpolated.plugins().get(), "Interpolated --plugins should be true");
192197
}
198+
199+
@Test
200+
void helpMentionsInferInDefault() throws Exception {
201+
ByteArrayOutputStream out = new ByteArrayOutputStream();
202+
ByteArrayOutputStream err = new ByteArrayOutputStream();
203+
204+
int exit = MavenUpCling.main(
205+
new String[] {"--help"},
206+
new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader()),
207+
null,
208+
out,
209+
err);
210+
211+
String help = out.toString(StandardCharsets.UTF_8);
212+
assertEquals(0, exit, "mvnup --help should exit 0");
213+
assertTrue(
214+
help.contains("Default behavior: --model --plugins --infer"),
215+
"Help footer should advertise --infer as part of the defaults");
216+
assertFalse(
217+
help.contains("Default behavior: --model and --plugins"), "Old/incorrect default text must be gone");
218+
}
193219
}

0 commit comments

Comments
 (0)