-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EnumSet<> options #628
Comments
Can you run again with |
Thank you for raising this issue! I was able to reproduce the problem, please ignore my previous comment. This is a shortcoming in the current version of picocli. Both problems have the same cause: picocli detects that The problem is that picocli currently has no special treatment for At the moment the workaround is to either:
With that last workaround, this test passes: enum ResultTypes {
NONE,
PARTIAL,
COMPLETE
}
@Test
public void testEnumSet() {
class App {
@Option(names = "--result-types", split = ",") //, converter = ResultTypesEnumSetConverter.class)
//private EnumSet<ResultTypes> resultTypes = EnumSet.of(ResultTypes.COMPLETE);
private EnumSet<ResultTypes> resultTypes = EnumSet.noneOf(ResultTypes.class);
}
App app = new App();
new CommandLine(app).parseArgs("--result-types", "PARTIAL,COMPLETE");
assertEquals(EnumSet.of(PARTIAL, COMPLETE), app.resultTypes);
} I am a big fan of using |
Many thanks for your prompt response and help. I've used your workaround and, because I need to set a default value, rather than assigning it in the code (which causes the exception) I can use a IDefaultValueProvider. |
…tional parameters in `EnumSet<>` collections
…tional parameters in `EnumSet<>` collections
Fixed in master and the 3.9.x branch. Please verify. |
Picocli 3.9.4 with a fix for this issue has been released. Enjoy! |
I have a enum and I want an argument to be an EnumSet so I can set flags on the CLI, for example:
with code similar to:
But I get the error when executed:
I have written a converter to parse the string:
but this doesn't seem to work:
The text was updated successfully, but these errors were encountered: