Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@
*/
@Experimental
public interface UpgradeOptions extends Options {
/**
* Should the operation be forced (ie overwrite existing files, if any).
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
Optional<Boolean> force();

/**
* Should imply "yes" to all questions.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
Optional<Boolean> yes();

/**
* Returns the list of upgrade goals to be executed.
* These goals can include operations like "check", "dependencies", "plugins", etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ protected CommonsCliUpgradeOptions(String source, CLIManager cliManager, Command
super(source, cliManager, commandLine);
}

@Override
@Nonnull
public Optional<Boolean> force() {
if (commandLine.hasOption(CLIManager.FORCE)) {
return Optional.of(Boolean.TRUE);
}
return Optional.empty();
}

@Override
@Nonnull
public Optional<Boolean> yes() {
if (commandLine.hasOption(CLIManager.YES)) {
return Optional.of(Boolean.TRUE);
}
return Optional.empty();
}

@Override
@Nonnull
public Optional<List<String>> goals() {
Expand Down Expand Up @@ -143,8 +125,6 @@ public void displayHelp(ParserRequest request, Consumer<String> printStream) {
printStream.accept(" --plugins Upgrade plugins known to fail with Maven 4");
printStream.accept(
" -a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
printStream.accept(" -f, --force Overwrite files without asking for confirmation");
printStream.accept(" -y, --yes Answer \"yes\" to all prompts automatically");
printStream.accept("");
printStream.accept("Default behavior: --model and --plugins are applied if no other options are specified");
printStream.accept("");
Expand All @@ -157,8 +137,6 @@ protected CommonsCliUpgradeOptions copy(
}

protected static class CLIManager extends CommonsCliOptions.CLIManager {
public static final String FORCE = "f";
public static final String YES = "y";
public static final String MODEL_VERSION = "m";
public static final String DIRECTORY = "d";
public static final String INFER = "i";
Expand All @@ -169,14 +147,6 @@ protected static class CLIManager extends CommonsCliOptions.CLIManager {
@Override
protected void prepareOptions(org.apache.commons.cli.Options options) {
super.prepareOptions(options);
options.addOption(Option.builder(FORCE)
.longOpt("force")
.desc("Should overwrite without asking any configuration?")
.build());
options.addOption(Option.builder(YES)
.longOpt("yes")
.desc("Should imply user answered \"yes\" to all incoming questions?")
.build());
options.addOption(Option.builder(MODEL_VERSION)
.longOpt("model-version")
.hasArg()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public int execute(UpgradeContext context) throws Exception {
context.info(" --plugins Upgrade plugins known to fail with Maven 4");
context.info(
"-a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
context.info("-f, --force Overwrite files without asking for confirmation");
context.info("-y, --yes Answer \"yes\" to all prompts automatically");
context.unindent();
context.println();
context.info("Default behavior: --model and --plugins are applied if no other options are specified");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,4 @@ void testHelpIncludesDefaultBehavior() throws Exception {
Mockito.verify(context.logger)
.info("Default behavior: --model and --plugins are applied if no other options are specified");
}

@Test
void testHelpIncludesForceAndYesOptions() throws Exception {
UpgradeContext context = createMockContext();

help.execute(context);

// Verify that --force and --yes options are included
Mockito.verify(context.logger).info(" -f, --force Overwrite files without asking for confirmation");
Mockito.verify(context.logger).info(" -y, --yes Answer \"yes\" to all prompts automatically");
}
}
Loading