Written on 2019-05-12.
As a small weekend project I wrote my own
Dotenv-CLI is a simple package that provides the
dotenv command. It reads
.env file from the current directory puts the contents in the
environment and executes the given command.
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="multi\nline" # some comment
$ 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=multi line
env is a simple command that outputs the current environment
dotenv CLI comes in handy if you follow the 12 factor
app methodology or just need to run a program locally with
specific environment variables set.
While dotenv-cli is certainly not the first
implementation, this one is written in Python and has no external dependencies
except Python itself. It also provides a bash completion, so you can prefix
any command with
dotenv while still be able to use completion:
$ dotenv make <TAB> all clean docs lint release test
Since there's also some other popular shells out there and I already struggled
writing the simple bash completion script, it would be very nice if some more
fish-, etc.- users could help me out in providing
completions for them as well.
dotenv-cli is available on Debian and Ubuntu:
$ sudo apt-get install python3-dotenv-cli
and on PyPi as well:
$ pip install dotenv-cli
This entry was tagged debian and dotenv-cli