Skip to content
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

DOC: user manual should show how to configure null defaultValue and fallbackValue #967

Closed
remkop opened this issue Feb 29, 2020 · 1 comment

Comments

@remkop
Copy link
Owner

remkop commented Feb 29, 2020

Request from the picocli google group mailing list:

If a list option is specified on the commandline without a value I end up with an ArrayList with index 0 set to empty String.

For example for below cli, I want myList to be set an empty List or even just set to null.

java FallbackValueDemo -myList
@Option(
    names = "-myList",
    split = ",",
    arity = "0..1",
    fallbackValue = {}) // TBD
List<String> myList;

I can see how this could be useful.

This seems closely related to #879

If we go with the suggestion in #879, it becomes possible to specify {} as the fallback, which would mean an empty list. Seems doable.

@remkop remkop added this to the 5.0 milestone Mar 1, 2020
@remkop remkop changed the title Support multi-value fallbackValue Document null defaultValue and fallbackValue Feb 21, 2022
@remkop remkop modified the milestones: 5.0, 4.7 Feb 21, 2022
@remkop
Copy link
Owner Author

remkop commented Feb 21, 2022

The user manual documents that default value and fallback value can be set to null or Optional.empty() with Option.NULL_VALUE, but this information is not mentioned in the section on Default Values.

Add a subsection to Default Values to clarify how applications can get null or Optional.empty() default values or fallback values.

@remkop remkop changed the title Document null defaultValue and fallbackValue DOC: user manual should show how to configure null defaultValue and fallbackValue Feb 22, 2022
@remkop remkop closed this as completed in de0d0e2 Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant