envy
envy copied to clipboard
Fallback to .env file like dotenv in Node
First of all, thanks for the fantastic library!
💡 Feature description
I think it would've been great to support dotenv-like behavior in envy.
That Node library can read environment variables from either environment variables directly (like envy does) or via .env
file, which is super convenient during the local development, cause we can have .env.example
with some default values for the development environment.
💻 Basic example
As an example, I can provide my own pet project where I played around with envy to actually make it work as I want.
As you can see, in load_config
we, first of all, try to load env variables as usual with envy and if it fails, we try to load and parse .env
file into the environment variables and re-read them again. And only after that, the final fail happens. This way, I can run the project from CLion without any additional configuration and explicit default values in the code.
Of course, it could be re-implemented in a different way, if it was to become a part of envy.
@slvrtrn You can do own logic before parse. #65 https://github.com/softprops/envy/issues/65#issuecomment-1440561228