-
Notifications
You must be signed in to change notification settings - Fork 518
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
HDDS-11878. Use CommandSpec to find top-level command #7575
Conversation
@nandakumar131 please review. This is based on your comment about removing |
Thanks @adoroszlai for working on this. |
Not related to this change:
and
Can we unify this as well? I can take it up. |
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.
LGTM.
@@ -105,7 +105,6 @@ public Void call() throws Exception { | |||
throw new MissingSubcommandException(cmd); | |||
} | |||
|
|||
@Override | |||
public OzoneConfiguration createOzoneConfiguration() { |
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.
This can be made private and only expose getOzoneConf
to avoid creating multiple OzoneConfiguration
. We can do this in a follow-up jira.
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.
Created HDDS-11992 for this, please feel free to pick up, if you have time, otherwise I can work on it.
Thanks @adoroszlai for the contribution! |
Thanks @nandakumar131 for reviewing and merging this.
Good point, but actually neither of these are necessary with the current version of picocli. This will be cleaned up in HDDS-11880. |
What changes were proposed in this pull request?
Problem
GenericParentCommand
provides a way to accessGenericCli
methods from sub-subcommands. However, its usage is tedious and comes with boilerplate code that needs to:GenericParentCommand
@ParentCommand
(injected by picocli)Adding new methods to
GenericParentCommand
becomes harder the more implementations we have. The interface needs to be implemented on all sub-command levels.Currently only very few implementations exists. Some subcommands access top-level command via similar parent chain, but without implementing
GenericParentCommand
.Solution
Picocli keeps track of the command hierarchy and allows accessing the top-level command directly via
CommandSpec
.Changes in this PR:
AbstractSubcommand
/AbstractMixin
base classes. Subcommands/mixins that want to access the top-level command can do so easily by extending it.GenericParentCommand
.Accessing the top-level command directly makes it easier to reorganize subcommands, add them to different parents, or even multiple parents at different levels.
https://issues.apache.org/jira/browse/HDDS-11878
How was this patch tested?
Tested some of the commands changed, that they still reflect the
--verbose
flag:CI:
https://github.com/adoroszlai/ozone/actions/runs/12428823594