-
I have a couple of applications that I would like to share subcommands. I have a set of parameters that are shared between all the commands, and would like to pass them on to the subcommands. My idea was to make the top commands implement an interface for the stuff that is shared between the commands, and have that interface referenced to using ParentCommand annotation. I have yet to make that work. So the question is, is it at all possible to use an interface for @ParentCommand? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Only fields can be annotated with
You would still have some duplicate code, but it is fairly minimal (essentially just wiring). |
Beta Was this translation helpful? Give feedback.
Only fields can be annotated with
@ParentCommand
, so you cannot directly use it in the interface itself.One idea is to create a
getParentCommand
method in your interface, and have the implementation classes implement it like this:You would still have some duplicate code, but it is fairly minimal (essentially just wiring).