-
Notifications
You must be signed in to change notification settings - Fork 427
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
Custom Factory
fails to create collection for @Option
s
#784
Comments
You are right. The recommended way to fix this is to delegate to the picocli default factory if the requested bean cannot be found in the configuration. This is what the built-in PicocliSpringFactory does. Something like this: @Override
public <K> K create(Class<K> clazz) throws Exception {
try {
return getBeanOrCreate(clazz); // ask the dependency injection container
} catch (Exception e) {
return CommandLine.defaultFactory().create(clazz); // fallback if missing
}
} I tried to track down when the change was made to delegate the creation of I am thinking to update the 4.0 release notes to add this to the list of breaking changes. I will also update the Guice example to add a try/catch and fall back to the picocli default factory as in the above example. |
That works, thanks a lot! |
… should fall back to the default factory to enable the creation of collections for `@Option`-annotated methods and fields.
User manual updated, and added entry to the 4.0 release notes under breaking changes. |
Right now, for the following command method option:
I'm getting the following exception:
My
Factory
is pretty simple, which simply delegates to Guice. But since I don't have a component created for options, it fails. This behavior seems to have changed between 3.x and 4.x, but I'm not sure how to resolve for command methods. I was able to fix it for fields by supplying a default field value.The text was updated successfully, but these errors were encountered: