0

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 )

4

1 回答 1

0

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().

于 2018-09-21T13:23:07.997 回答