-
Notifications
You must be signed in to change notification settings - Fork 445
Description
From the picocli google group by @maxandersen:
I might already asked this but couldn't find the answer...
is there a way to have something like:
@CommandLine.Option(names = { "--D" })
Map<String, Optional> properties;similar to how key/value properties works in maven that -Dxyx means xyz is set.
in other words - anyway to mark that the [=value] part is optional ?
(my reply on the mailing list)
Currently (as of picocli 4.5.1), unfortunately not:
picocli will throw an exception (Value for option -D should be in KEY=VALUE format but was xyz)
if the value for the -D option does not contain a '=' character.
Would you mind raising a ticket on the picocli GitHub issue tracker for this? (It is easier for me to track TODO items on GitHub than on Google groups...)
There are several ways this could be improved:
- make the value optional if the Map is defined with Optional for the value type: Map<KeyType, Optional>
- have a parser option like CommandLine.setMapOptionsRequireValue (default true for backwards compatibility)
- have an annotation attribute like fallbackValue (perhaps a different one, unsure if it is a good idea to use the existing
fallbackValueattribute for this) - it would also be nice to have some way for applications to customize the Key-Value separator (currently it is hard-coded to '=')