-
Notifications
You must be signed in to change notification settings - Fork 658
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
SOLR-17442: Resolve -v flag conflict (version, value, verbose) #2721
Conversation
…olr maybe we have a "info" tool seperate from -v and --version. Tweak the help output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention in the ticket that introducing -d
for debug
may require further deprecations where -d
is used for other options as well.
@@ -148,9 +154,21 @@ public class SolrCLI implements CLIO { | |||
public static final Option OPTION_VERBOSE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we mark deprecated options with @Deprecated
? If so, this would be beneficial for OPTION_VERBOSE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, I hadn't thought about that use.... Good catch, and we should.
.deprecated( | ||
DeprecatedAttributes.builder() | ||
.setForRemoval(true) | ||
.setSince("9.7") | ||
.setDescription("Use --solr-url instead") | ||
.get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this as a note: Splitting url
from solr-url
would have a way too large impact in the rest of the tools, so simply marking both as deprecated is a good tradeoff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, I actually don't know why I added this... It doesn't seem to fit the rest of this PR...
if (!cli.hasOption((SolrCLI.OPTION_DEBUG.getOpt())) | ||
|| cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By putting both options (verbose and debug) into an OptionGroup
, this can be simplified as well.
public static final Option OPTION_DEBUG = | ||
Option.builder("d") | ||
.longOpt("debug") | ||
.required(false) | ||
.desc("Enable additional command output.") | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if we would go for the --debug
option. Shall we also deprecate the -d
for all the other arguments as well in this PR? We use -d
in quite a few places and providing the -d
now for debug
to all tools may cause unexpected behavior.
I am wondering if we should just stick to |
I checked what Docker does, just for run, and they use
I am kind of leaning towards avoiding the whole |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should start sooner using OptionGroup
s. I realized in this review and after testing it that we could simplify a lot of logic with them.
Many comments but mostly minor or repetitive things.
debug = | ||
cli.hasOption((SolrCLI.OPTION_DEBUG.getOpt())) | ||
|| cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With an OptionGroup
this could be simplified to debug = cli.hasOption(SolrCLI.OPTION_DEBUG)
, where SolrCLI.OPTION_DEBUG
is the OptionGroup
that includes verbose and debug options.
Note that the help outputs may be different if using option groups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to dig more in and write a unit test to prove that works!
if (cli.hasOption((SolrCLI.OPTION_DEBUG.getOpt())) | ||
|| cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and here (OptionGroup
).
print("such as: ./solr start --help or ./solr stop -h"); | ||
print("Global Options:"); | ||
print(" -v, --version Print version information and quit"); | ||
print(" -d, --debug Enable debug mode"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-d
should probably not included here.
cli.hasOption((SolrCLI.OPTION_DEBUG.getOpt())) | ||
|| cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OptionGroup
simplification.
if (cli.hasOption((SolrCLI.OPTION_DEBUG.getOpt())) | ||
|| cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OptionGroup
simplification.
@malliaridis I was able to integrate OptionGroup for the --debug and --verbose options in this PR and it works. What I haven't been able to grok is how to simplify the checking for the flags. You still have to check for each it apepars!! If you find some code that avoids that, let me know. I am going to open a fresh PR that uses optiongroups more widely. |
I was at the point of merging and the --debug syntax just bugged me. I am backing it out and just keep --verbose which rings better for me, and still accomplishs the goal of making -v no longer overlap. |
I see that you are using the There is also a You can also set things like Option.builder("v")
.longOpt("value")
.deprecated(...)
.required(false)
//...
Option.builder()
.longOpt("value")
.required(false) // should be true when -v is removed.
//...
String value = SolrCLI.getOptionWithDeprecatedAndDefault(cli, "value", "v", null);
//...
if (value == null) {
throw new MissingArgumentException("'value' is a required option.");
} Using |
Deprecate the various uses of -v, so that we don't have conflicts there. --------- Signed-off-by: Eric Pugh <[email protected]> (cherry picked from commit eda5ec3)
.deprecated( | ||
DeprecatedAttributes.builder() | ||
.setForRemoval(true) | ||
.setSince("9.8") | ||
.setDescription("Use --debug instead") | ||
.get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@epugh could you review this file again? I think this should be undone if we won't introduce --debug
and deprecate -v
for version (below too).
https://issues.apache.org/jira/browse/SOLR-17442
Description
Deprecating -v in favour of -d.
Solution
Please provide a short description of the approach taken to implement your solution.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.