dotenv CLI
Dotenv-CLI provides the dotenv command. dotenv loads the .env file from
the current directory, puts the contents in the environment by either changing
existing- or adding new environment variables, and executes the given command.
dotenv supports alternative .env files like .env.development via the -e
or --dotenv parameters. This parameter can be repeated to load multiple
files, the .env files will be loaded in the order they are provided.
With the --replace flag, dotenv also provides an option to completely
replace the environment variables with the ones from the .env file, allowing
you to control exactly which environment variables are set.
dotenv provides bash completion, so you can use dotenv like this:
$ dotenv make <TAB>
all clean docs lint release test
Install
Using PyPi
dotenv-cli is available on PyPi, you can install it via:
$ pip install dotenv-cli
On Debian and Ubuntu
Alternatively, you can install dotenv-cli on Debian based distributions via:
# apt-get install dotenv-cli
Usage
Create an .env file in the root of your project and populate it with some
values like so:
SOME_SECRET=donttrythisathome
SOME_CONFIG=foo
Just prepend the command you want to run with the extra environment variables
from the .env file with dotenv:
$ dotenv some-command
and those variables will be available in your environment variables.
Rules
The parser understands the following:
- Basic unquoted values (
BASIC=basic basic) - Lines starting with
export(export EXPORT=foo), so you cansourcethe file in bash - Lines starting with
#are ignored (# Comment) - Empty values (
EMPTY=) become empty strings - Inner quotes are maintained in basic values:
INNER_QUOTES=this 'is' a testorINNER_QUOTES2=this "is" a test - White spaces are trimmed from unquoted values:
TRIM_WHITESPACE= fooand maintained in quoted values:KEEP_WHITESPACE=" foo " - Interpret escapes (e.g.
\n) in double quoted values, keep them as-is in single quoted values.
Example .env file:
BASIC=basic basic
export EXPORT=foo
EMPTY=
INNER_QUOTES=this 'is' a test
INNER_QUOTES2=this "is" a test
TRIM_WHITESPACE= foo
KEEP_WHITESPACE=" foo "
MULTILINE_DQ="multi\nline"
MULTILINE_SQ='multi\nline'
MULTILINE_NQ=multi\nline
#
# some comment
becomes:
$ dotenv env
BASIC=basic basic
EXPORT=foo
EMPTY=
INNER_QUOTES=this 'is' a test
INNER_QUOTES2=this "is" a test
TRIM_WHITESPACE=foo
KEEP_WHITESPACE= foo
MULTILINE_DQ=multi
line
MULTILINE_SQ=multi\nline
MULTILINE_NQ=multi\nline
Metadata
Release files for dotenv-cli 3.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dotenv_cli-3.4.1.tar.gz | 9.4 kB | Without provenance | Details for dotenv_cli-3.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dotenv_cli-3.4.1-py3-none-any.whl | Python 3 | none | any | Details for dotenv_cli-3.4.1-py3-none-any.whl |
Total release size: 16.5 kB
Release files / dotenv_cli-3.4.1.tar.gz
| Download URL | dotenv_cli-3.4.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8357511e041eda48b6a9f310d416cbfcee4aaeef7f66b2cb817031ac15de3c2d
|
|
BLAKE2b-256 checksum How to use checksums |
7d0c24d1332d85ec949a77c2e9422b682724026004df8d919a202073ebdc0276
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / dotenv_cli-3.4.1-py3-none-any.whl
| Download URL | dotenv_cli-3.4.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69f8ee14788d9cf611de022746a6486a87ccc672e95b73eb333e887e904e0053
|
|
BLAKE2b-256 checksum How to use checksums |
2cbb90dc3d9babb1ec8effebd379bce95966b3f9830306efd4578189e2e3a520
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for dotenv-cli 3.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.