peterbourgon / ff

Flags-first package for configuration
Apache License 2.0
1.34k stars 59 forks source link

flags/env vars #91

Closed jimenezna06 closed 2 years ago

jimenezna06 commented 2 years ago

I noticed that ffcli and ff doesn’t seem to load config from env vars. Is there a way to make sure it defaults to env vars? instead of having the flag override the env var if an env var exists. I am using the function: ff.Parse(fs, os.Args[1:], ff.WithEnvVarNoPrefix())

peterbourgon commented 2 years ago

To be clear, you're saying that you want

env FOO=123 myprogram -foo=456

to set foo to 123, not 456?

jimenezna06 commented 2 years ago

if you set a flag the exec uses the flag if no flag is set it used env var if nothing is set it doesn’t work in other words a flag overrides the env var if an env var exists unless ff doesn’t allow it but I think it does?

does it allow this?

peterbourgon commented 2 years ago

What you described is exactly how it works currently. Is it not the case for you?