envconfig icon indicating copy to clipboard operation
envconfig copied to clipboard

Variables with an override don't play nice with logs from Usage and Process

Open cv711 opened this issue 7 years ago • 3 comments

Let's say I define a bunch of variables but one of them has an override e.g.

LogLevel string desc:"Log level override" envconfig:"LOG_LEVEL"

then I would expect that a call to envconfig.Usage("CMD", &cfg) should print it as LOG_LEVEL ..., instead of that I get CMD_LOG_LEVEL.

Same thing seems to be happening with the error from envconfig.Process("CMD", &cfg). When missing a required variable with an override I get required key CMD_LOG_LEVEL missing value as a message.

Thanks, Chris

cv711 avatar Jul 03 '17 17:07 cv711

You're totally right here. I believe the code would accept either <prefix>_<name> or just <name> (when tagged with "envconfig"), but the non-prefixed version should definitely be favored. I'd happily merge a PR that fixed this :)

teepark avatar Sep 18 '17 18:09 teepark

@cv711 Please read README.md. There is sufficient information to resolve your question.

@teepark This issue should get closed.

TonyPythoneer avatar Aug 18 '19 13:08 TonyPythoneer

@TonyPythoneer I also need to have the Usage() print the alternate names instead of the key. I looked at the README.md and did not find the info on how to do it. Can you point me in the right direction?

ronniel1 avatar Jul 07 '20 10:07 ronniel1