cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.96k stars 334 forks source link

Invoke IDefaultProvider only if needed #470

Open mkarg opened 5 years ago

mkarg commented 5 years ago

Apparently IDefaultProvider is invoked multiple times for the same parameter, once per each of its names, even in case an explicit value is given, i. e. when no default is needed at all.

This is not nice, especially when creation of the default is an expensive operation. For example, when the default provider needs to perform I/O, or expensive cryptographic calculations etc. each default provision invocation might need seconds, while the explicitly provided value for that parameter effectively means "skip all of these costly things"...

Hence it would be great if IDefaultProvider is...