CLI to print environment variables from supported sources.
Project description
print-env
CLI to print environment variables from supported sources.
This is derived from projects that:
- Use environment variables as the main interface for configuration
- Use source-control ignored files to store environment variables for scenarios such as local development
Install
$ pipenv install print-env
# or
$ pip install print-env
Usage
Assume a .env
file that contains the following content:
# .env
FLASK_APP=app.py
FLASK_DEBUG=1
SQL_URI=<SQL connection string that may contain credentials>
# and more...
Then simply
$ print-env
FLASK_APP=app.py FLASK_DEBUG=1 SQL_URI=<redacted> # and more...
The above would print out environment variables stored in .env
, or env.yml
, or env.json
(roughly attempted in this order). You can also exclusively specify the file:
$ print-env /path/to/env/file.yml
and the script would attempt to parse the file based on its extension given. Note that any file extension that is not of YAML or JSON type is attempted as a dotenv file.
In fact, you can specify a series of files. Note that in case of duplicates, the last files take precedence, for example:
# content of base.env
LOG_LVL=warning
API_TOKEN=aabbcc
# content of dev.env
LOG_LVL=debug
$ print-env base.env dev.env
LOG_LVL=debug API_TOKEN=aabbcc
Another common case is when an external file is used to supply environment variables at deploy-time, for example, when used with the serverless framework with a serverless.yml
that may look like:
service: env-vars
package:
exclude:
- node_modules/**
- '*env.yml'
- Pipefile
- Pipfile.lock
functions:
test:
# test.py - handler()
handler: test.handler
# sourcing env vars from ./env.yml
environment: ${file(./env.yml):}
and for local test runs you can utilize print-env
to reuse the same env.yml
:
$ env $(print-env) python test.py # omitted file path since env.yml is on the default try-list
Similarly, print-env
can be used for build-time configuration. For example, with an imaginary client-side project with a package.json
that may look like:
{
"name": "TestApp",
"version": "1.0.1",
"scripts": {
"build": "env $(print-env local-env.json) parcel build index.html",
"build:dev": "env $(print-env dev-env.json) parcel build index.html",
"build:prod": "env $(print-env prod-env.json) parcel build index.html"
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file print-env-2.3.0.tar.gz
.
File metadata
- Download URL: print-env-2.3.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a787aabc2c34c0fb3bb3b2353d32b97596b25a9606a1a793e0abb255de1fa19 |
|
MD5 | 16d53d3b58bb29fe443f3cc3b2e3bf4e |
|
BLAKE2b-256 | 09737d7fc297c8f82d2b13f9c26ea7d1cec418d4156fcd053422060ec02470e1 |
File details
Details for the file print_env-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: print_env-2.3.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f5618573f4de7449ededaac31bb4b7466688fa7bec22c5655190f5234057f6c |
|
MD5 | fd89ec8b9bba6d6fb21ae4bcf4e29e0d |
|
BLAKE2b-256 | 2882c83c81d1729b2ca6e67e86f9a6830888cfc4f1f49469017ca38f64d21e5e |