Skip to content

Conversation

@chickencoding123
Copy link

This adds support for dotenv file format. It is accomplished by using dotenvy crate. There's an open issue asking for this feature here #16.

@coveralls
Copy link

coveralls commented Oct 22, 2025

Pull Request Test Coverage Report for Build 18750157020

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 64.846%

Totals Coverage Status
Change from base Build 18169995909: 0.0%
Covered Lines: 950
Relevant Lines: 1465

💛 - Coveralls

Comment on lines +63 to +66

/// Dotenv (parsed with `dotenvy`)
#[cfg(feature = "dotenv")]
Dotenv,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work as another FileFormat / Source? I suspect there is a lot of design overlap with Environment that we'd want to make this functionality on that.

Copy link
Author

@chickencoding123 chickencoding123 Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another FileFormat. You can see the usage from the tests (added snippet for ref. here). It is similar to existing file formats. Also dotenvy dependency will take care of the overlap, if any. However I ensured OS env take precedence as per existing file formats.

 let s = Config::builder()
        .add_source(config::File::from_str(
            r#"
                FOO=bar
                BAZ=qux
            "#,
            config::FileFormat::Dotenv,
        ))
        .build()
        .unwrap();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI resolving conversations that aren't ready for it can make PR reviews more difficult on maintainers. You should be pretty confident that you understood the concern and responded to it as the maintainer expected to resolve it. That was not the case here.

Some traits of dotenv are

  • Stringly typed (so is ini)
  • Unstructured

Both of these characteristics are shared with Environment which has a lot of functionality for solving these problems. In fact, this is another form of environment variables! The only difference is it also shares some of the file loading characteristics of file formats.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've raised this (and other questions) at #16 (comment) as I prefer to work out high level designs in Issues rather than PRs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to strike a balance between dotenv ambitions and preferences of this repository.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of any dotenv "ambitions" that come in conflict with "preferences of this repository". Also, for any "preferences" I'm giving, they are about fully supporting dotenv rather than doing it party way.

@epage
Copy link
Contributor

epage commented Oct 23, 2025

Feel free to modify your commits for how they should be merged

@chickencoding123 chickencoding123 changed the title feat: adding support for dotenv files feat(dotenv): Adding support for dotenv files Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants