So I'm using picocli and I'm trying to generalize some of my commands in a project.
I have 2 classes which share some methods, where one is an extension of the other. They both have options for CLI, but the subclass only needs some of those options, so here's the problem.
When I extend the class picocli also takes all the declared options in the superclass, is there a way I can choose what options I want?
I have tried reading into the subclassing and mixins in the docs here but I don't seem to see how I can choose what options I want to inherit from the superclass. There is also inheritance scope here which I have tried adding to the superclasses options like:
@Option(name = "bar", required = yes, scope = ScopeType.LOCAL)
but when I run the class B in the CMD, it still requires me to pass in the bar option parameter.
@Command(name = "cmd1")
class A implements Callable<Integer> {
@Option(name = "foo", required = yes)
protected String var1;
@Option(name = "bar", required = yes)
private String var2;
Integer call(){}
void extraMethodIWantToExtend1(){}
void extraMethodIWantToExtend2(){}
}
Then we have class B which I want it to extend class A for its methods but I only need var1 from class A not var2.
@Command(name = "cmd2")
class B extends A implements Callable<Integer> {
@Option(name = "extraOption", required = yes)
private String var3;
//I still want to make use of the var1 from the superclass but not var2
Integer call(){
System.out.println(var1)
}
}