CLI to print environment variables from supported files.
Project description
print-env
CLI to print environment variables from supported files.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file print-env-0.1.4.tar.gz.
File metadata
- Download URL: print-env-0.1.4.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de10a9129fd7f0d1815fa817d3d73b62de60f2811966bce8865203a9d8ed04ec
|
|
| MD5 |
88c800bdb66259be7614e8db24810a85
|
|
| BLAKE2b-256 |
1d161eb633ce926fcbf3c9306568a95dfd264f2647561b20dc035630d8785719
|
File details
Details for the file print_env-0.1.4-py3-none-any.whl.
File metadata
- Download URL: print_env-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d0463101221a9386c7d1aac55ab7f5c7e6e0235f811ecdd2adaac786c0be497
|
|
| MD5 |
ff8e533be3a57b59997fea8d5487bfbc
|
|
| BLAKE2b-256 |
830bd0173fc29312d4e16b17c30745824653abcae8032f9897ddd6d92423b1be
|