Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8348] Fix typos in deprecation warning message #1844

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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 @@ -219,16 +219,22 @@ public void warnAboutDeprecatedOptions(ParserRequest request, Consumer<String> p
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());
Expand Down Expand Up @@ -415,14 +421,18 @@ public CommandLine parse(String[] args) throws ParseException {
// 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
options.getOptions().forEach(commandLine::hasOption);
return commandLine;
}

protected void addDeprecatedOption(Option option) {
usedDeprecatedOptions.add(option);
}

public org.apache.commons.cli.Options getOptions() {
return options;
}
Expand Down