cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.95k stars 332 forks source link

Combining required=true with defaults #517

Open mkarg opened 3 years ago

mkarg commented 3 years ago

Currently required=true enforces the explicit provision of a parameter at the command line. In fact, it would be very useful, is a default would be considered, i. e. the error message requesting the missing parameter only pops up if the default (provided either by a static initializationg function or by a IDefaultProvider) actually is null. The idea behind this is that an essential parameter can be loaded by a default provider, but if that fails the user can override by explicitly provide the parameter.

nbuesing commented 1 year ago

this feature would be helpful when initializing a class through some environment variable loading and then wanting them provided on the command line, only if not pre-populated.