You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I'm trying to do: I have an existing API that has multiple values for list formats and I would like to switch them on with a flag type mechanism. They are mutually exclusive -- you can't have a short and a long list format, for instance.
This seems to be a great chance to use @ArgGroup(exclusive = true) and @Option(...) on a method in the exclusive options. The method simply sets the correct value to the actual parameter. (There are multiple methods settings values. One for each list format.)
What happens: A NullPointerException is generated like this:
$ bin/picocli-experiments list file1 file2
NullPointerException: null while processing argument at or before arg[0] 'list' in [list, file1, file2]: java.lang.NullPointerException
If I switch from a method to a boolean flag annotated with @Option, and then write the if-logic to calculate the value, it works fine. But that's pretty ugly.
From what little I've been able to determine from debugging, the scope is never set in Interpreter.applyGroupDefaults() in line 11075 -- the if (arg.scope().get() != null) is what fails.
Using picocli version 4.0.4.
(P.S. Excellent tool, really like it a lot.)
(P.P.S. sample.zip is attached for a more cohesive use case.)
The text was updated successfully, but these errors were encountered:
I’ve only been able to spend a little bit of time investigating, but I suspect that this only happens in subcommands. All my tests for argument groups are with top-level commands. Definitely some problem in the initialization.
Still need to look further...
What I'm trying to do: I have an existing API that has multiple values for list formats and I would like to switch them on with a flag type mechanism. They are mutually exclusive -- you can't have a short and a long list format, for instance.
This seems to be a great chance to use
@ArgGroup(exclusive = true)
and@Option(...)
on a method in the exclusive options. The method simply sets the correct value to the actual parameter. (There are multiple methods settings values. One for each list format.)What happens: A NullPointerException is generated like this:
If I switch from a method to a boolean flag annotated with
@Option
, and then write the if-logic to calculate the value, it works fine. But that's pretty ugly.From what little I've been able to determine from debugging, the scope is never set in
Interpreter.applyGroupDefaults()
in line 11075 -- theif (arg.scope().get() != null)
is what fails.Using picocli version 4.0.4.
(P.S. Excellent tool, really like it a lot.)
(P.P.S. sample.zip is attached for a more cohesive use case.)
The text was updated successfully, but these errors were encountered: