Skip to content

Fallback to .env file like dotenv in Node #62

Open
@slvrtrn

Description

@slvrtrn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions