Automatically reading from alternative sources #2095
Unanswered
absolutejam
asked this question in
Q&A
Replies: 1 comment
-
|
Ah, it looks like #2032 (comment) is related. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
I'm using v3 and I'm curious if there's a way to automatically register
Sourcesfor all flags? Perhaps in theBeforefunc?I tried the following:
But the flag doesn't seem to be reflected either in the help, or when I get the value. I also tried skipping the
Sourcesand just iterating over the commands' flags in theBeforefunction, and updating the flagValue- but that doesn't seem to have had any effect.I basically want to read from
Koanfusing the Command'sName, as a way of centralising all of the config from the Koanf (which leverages env & file providers), and I also write back to it in theBeforehook. This way I have base config from file & env, then flags can override/extend this config, and I have a unified interface for fetching config.I've created a custom source based on the file & env ones, and that works if I define it manually under
Sources. Also Ive noticed it adds[$app.key]to the end of the flag's help (The flag is--app.key) - Can this be defined/overridden anywhere?Cheers!
Beta Was this translation helpful? Give feedback.
All reactions