Reputation: 36834
I have a command with subcommands, which are registered declaratively, and I'm interested in using this style of command line processing:
List<Object> parsed = commandLine.parseWithHandler(new RunAll(), args);
However, for unit testing purposes, I want to access the subcommand object to see if it has the correct options set, etc. Is there a way to access the subcommand object when using RunAll
?
(See also https://github.com/remkop/picocli/issues/489 )
Upvotes: 0
Views: 352
Reputation: 36834
In the unit test, if you have access to the CommandLine
object, you can call CommandLine.getParseResult()
. You can query this object to see which options were matched. You can also descend into the subcommands with ParseResult.hasSubcommand()
and ParseResult.subcommand()
.
Upvotes: 0