load-env

Crates.ioload-env
lib.rsload-env
version0.3.0
sourcesrc
created_at2023-04-04 02:07:13.515813
updated_at2023-05-05 19:42:15.155272
descriptionA tool to load .env files
homepage
repository
max_upload_size
id829709
size4,233
Nick Muller (nikolaimuller)

documentation

README

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
Commit count: 0

cargo fmt