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 )

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.