picocli
picocli copied to clipboard
Mode for treating empty string the same as unspecified
This is similar in spirit to https://github.com/remkop/picocli/issues/1987
Basically, I want to be able to write CLIs such that explicitly passing empty-string as a param value is the same as having not specified the parameter at all. (e.g. --bar=x --foo=
is the same as --bar=x
). I suggest empty string because it's the closest thing BASH has to as "null" value. I see this as the best practice for optional parameters in any language.
In particular, I want support for default values to work correctly. For example:
@Option(name = "--my_enum") MyEnum myEnum = MyEnum.A
tool --my_enum=
would invoke tool
with MyEnum.A
as the value for myEnum
My objective is to make it easier to wrappers/scripts/etc to invoke tools with default values, without having to know what the default values are. Wrappers should be able to assume empty-string is the default value for every param.
Obviously this is a backward incompatible change, but could it be added as a setter on CommandLine
?