Get single environment variable
Get a single environment variable value.
Installation
dotenvx get HELLO
Returns a single environment variable. Unlike run, it doesn't inject anything. It just returns the value.
Usage
Given you have a .env
file like this:
# .env
HELLO="World"
GOODNIGHT="Sleep well my love."
Simply run dotenvx get HELLO
.
$ dotenvx get HELLO
World
Get a different variable
Or get GOODNIGHT
.
$ dotenvx get GOODNIGHT
Sleep well my love.
Pass optional flags
You can pass all the same options to get
that you can pass to run
. This way you can do string evaluation, expansion, different filepaths, .env.vault
injection, and more.
$ dotenvx get HELLO --env="HELLO=first" --env-file=.env --env="HELLO=last" --overload
last
To see a list of all options available:
$ dotenvx get --help
Return json
And lastly, you can return all keys and values as a json response if you prefer. Simpley, omit the KEY
argument and pass the --pretty-print
flag.
$ dotenvx get --pretty-print
{
"HELLO": "World",
"GOODNIGHT": "Sleep well my love."
}
Handy!