load-env

CLI wrapper for loading .env files, written in rust

Install

Install globally with cargo:

cargo install load-env

Usage

Create .env file in your project:

DATABASE_URL="postgres://user:password@host:port/db"

Load the .env with cli:

load-env <your-command>

Nesting and mode

You can use the naming convention for .env files, such as in nextjs, Vite, etc.

For example, create a .env.local for local usage:

```

.env.local

DATABASE_URL="postgres://user:password@host:port/db-local" ```

and .env.test.local for run tests:

```

.env.test.local

DATABASE_URL="postgres://user:password@host:port/db-test" ```

.env.local will be loaded in any case, for load .env.test.local you need to specify the mode flag:

load-env -m test <your-command>

Env Loading Priorities

.env # loaded in all cases .env.local # loaded in all cases, ignored by git .env.[mode] # only loaded in specified mode .env.[mode].local # only loaded in specified mode, ignored by git