Skip to content
Snippets Groups Projects
README.md 1.08 KiB
Newer Older
Louis's avatar
Louis committed
# Envish

Rust .env file library, with support for reading and parsing files from the filesystem or memory, updating the current environment from a .env file, and handling interpolated environment variables.

## Features

- [x] .env format parser
- [x] Preserves comments and file definition order, both inline and block
- [x] Read .env files from disk
- [x] Support suffixed .env files (e.g. ".env.release")
- [ ] Serialising .env format

## Usage

```toml
[dependencies]
envish = "0.1.0"
```

Call `dotenv()` At the location where you need to load from the environment (usually within the startup path). In this example,
note the order in which files are loaded; the library will not overwrite a value already set in the environment, so you should
load files from most to least specific if using more than one, as the first set value takes precedence.


```rust
use envish::{dotenv, dotenv_suffix};

fn main() {
    // Loads values from ".env.development", but only when running a debug build
    #[cfg(debug_assertions)]
    dotenv_suffix("development");

    // Loads values from ".env"
    dotenv();
}
```