You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,21 @@ Some applications load from `.env`, `.env.local`, `.env.development` and `.env.d
36
36
(see [#37](https://github.com/entropitor/dotenv-cli/issues/37) for more information).
37
37
`dotenv-cli` supports this using the `-c` flag for just `.env` and `.env.local` and `-c development` for the ones above.
38
38
39
+
### Setting variable from command line
40
+
It is possible to set variable directly from command line using the -v flag:
41
+
```bash
42
+
$ dotenv -v VARIABLE=somevalue <command with arguments>
43
+
```
44
+
45
+
Multiple variables can be specified:
46
+
```bash
47
+
$ dotenv -v VARIABLE1=somevalue1 -v VARIABLE2=somevalue2 <command with arguments>
48
+
```
49
+
50
+
Variables set up from command line have higher priority than from env files.
51
+
52
+
> Purpose of this is that standard approach `VARIABLE=somevalue <command with arguments>` doesn't work on Windows. The -v flag works on all the platforms.
53
+
39
54
### Check env variable
40
55
If you want to check the value of an environment variable, use the `-p` flag
' --debug output the files that would be processed but don\'t actually parse them or run the `command`',
15
15
' -e <path> parses the file <path> as a `.env` file and adds the variables to the environment',
16
16
' -e <path> multiple -e flags are allowed',
17
+
' -v <name>=<value> put variable <name> into environment using value <value>',
18
+
' -v <name>=<value> multiple -v flags are allowed',
17
19
' -p <variable> print value of <variable> to the console. If you specify this, you do not have to specify a `command`',
18
20
' -c [environment] support cascading env variables from `.env`, `.env.local`, `.env.<environment>`, `.env.<environment>.local` files',
19
21
' command `command` is the actual command you want to run. Best practice is to precede this command with ` -- `. Everything after `--` is considered to be your command. So any flags will not be parsed by this tool but be passed to your command. If you do not do it, this tool will strip those flags'
0 commit comments