Help with design a structure #2166
-
Hello all :) I'm new in the Picocli world. I'm working on rewriting a JCommander framework to Picocli. I would like to ask you for help. I need to create a structure something like that: Right now, it looks like that: AllArg.class:
What problem do I have?
I like very simple and 'clean code' solutions. I feel that I can't achieve this by myself, that I'm asking. Thank you for your time, and have a nice day :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Instead of From your diagram it sounds like you want something like this: @Command(subcommands = { Command1.class, Command2.class, Command3.class})
class Input { // maybe implements Runnable if this command also has functionality
@Option(names = {"-d", "--debug"}, scope = ScopeType.INHERIT) // option is shared with subcommands
boolean debug;
}
@Command
class Command1 implements Runnable { ... }
@Command
class Command2 implements Runnable { ... }
@Command(subcommands = { SubCommand1.class, SubCommand2.class, SubCommand3.class})
class Command3 implements Runnable {
@Option(names = "-x")
String x;
@Option(names = "-y")
String y;
public void run() {
// business logic for Command 3 here
}
} |
Beta Was this translation helpful? Give feedback.
Instead of
@ArgGroup
, I believe you want to use@Command
instead.From your diagram it sounds like you want something like this: