Skip to content

Commit

Permalink
SOLR-17442: Fix a errant deprecation of --debug and properly look up …
Browse files Browse the repository at this point in the history
…--verbose (apache#2732)

getOpt and getLongOpt are not equivalent.  getOpt only works if you have a one letter version of a command, so use getLongOpt for the --verbose flag.
  • Loading branch information
epugh authored Oct 1, 2024
1 parent d1e505a commit 30d34cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
11 changes: 10 additions & 1 deletion solr/core/src/java/org/apache/solr/cli/AssertTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,18 @@ public List<Option> getOptions() {
SolrCLI.OPTION_CREDENTIALS);
}

/**
* Returns 100 error code for a true "error", otherwise returns the number of tests that failed.
* Otherwise, very similar to the parent runTool method.
*
* @param cli the command line object
* @return 0 on success, or a number corresponding to number of tests that failed, or 100 for a
* Error
* @throws Exception if a tool failed, e.g. authentication failure
*/
@Override
public int runTool(CommandLine cli) throws Exception {
verbose = cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt());
verbose = cli.hasOption(SolrCLI.OPTION_VERBOSE.getLongOpt());

int toolExitStatus;
try {
Expand Down
11 changes: 3 additions & 8 deletions solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,12 @@ public class SolrCLI implements CLIO {
.build();

public static final Option OPTION_VERBOSE =
Option.builder("v")
Option.builder()
.longOpt("verbose")
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.8")
.setDescription("Use --debug instead")
.get())
.required(false)
.desc("Enable verbose command output.")
.build();

public static final Option OPTION_HELP =
Option.builder("h").longOpt("help").required(false).desc("Print this message.").build();

Expand Down Expand Up @@ -320,7 +315,7 @@ protected static void checkSslStoreSysProp(String solrInstallDir, String key) {
}

public static void raiseLogLevelUnlessVerbose(CommandLine cli) {
if (!cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) {
if (!cli.hasOption(SolrCLI.OPTION_VERBOSE.getLongOpt())) {
StartupLoggingUtils.changeLogLevel("WARN");
}
}
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/ToolBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void echo(final String msg) {

@Override
public int runTool(CommandLine cli) throws Exception {
verbose = cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt());
verbose = cli.hasOption(SolrCLI.OPTION_VERBOSE.getLongOpt());

int toolExitStatus = 0;
try {
Expand Down

0 comments on commit 30d34cb

Please sign in to comment.