Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: encourage use of -- as default practice #103

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@ pnpm add -g dotenv-cli
## Usage

```bash
$ dotenv <command with arguments>
$ dotenv -- <command with arguments>
```

This will load the variables from the .env file in the current working directory and then run the command (using the new set of environment variables).

Alternatively, if you do not need to pass arguments to the command, you can use the shorthand:

```bash
$ dotenv <command>
```

### Custom .env files
Another .env file could be specified using the -e flag:
```bash
$ dotenv -e .env2 <command with arguments>
$ dotenv -e .env2 -- <command with arguments>
```

Multiple .env files can be specified, and will be processed in order:
```bash
$ dotenv -e .env3 -e .env4 <command with arguments>
$ dotenv -e .env3 -e .env4 -- <command with arguments>
```

### Cascading env variables
Expand All @@ -48,12 +54,12 @@ dotenv -e ../.env -c
### Setting variable from command line
It is possible to set variable directly from command line using the -v flag:
```bash
$ dotenv -v VARIABLE=somevalue <command with arguments>
$ dotenv -v VARIABLE=somevalue -- <command with arguments>
```

Multiple variables can be specified:
```bash
$ dotenv -v VARIABLE1=somevalue1 -v VARIABLE2=somevalue2 <command with arguments>
$ dotenv -v VARIABLE1=somevalue1 -v VARIABLE2=somevalue2 -- <command with arguments>
```

Variables set up from command line have higher priority than from env files.
Expand Down