2.1.0
- Added
pyqwe[dotenv]
optional extra functionality intopyqwe
- Added advanced settings to change how env vars are loaded
pyqwe not has 'settings keys'
[tool.pyqwe]
__env_ignore__ = false
__env_marker_start__ = "{{"
__env_marker_end__ = "}}"
__env_files__ = [".env.example"]
These can be used to configure how pyqwe reads, and deals with environment variables.
Here's the updated readme section:
Using environment variables
To use environment variables in the command, use the {{ }}
markers, these markers are the default but can be changed.
pyqwe will evaluate any environment variables that are set before running any commands.
If pyqwe detects an environment variable that is not set, it will raise an error. An error will
also be raised if environment variables are detected, and you do not have python-dotenv
installed.
Here's an example of setting an environment variable in a command:
[tool.pyqwe]
talk = "*shell:echo {{MESSAGE}}"
You can change the environment variable markers by changing the __env_marker_start__
and __env_marker_end__
settings
keys.
[tool.pyqwe]
__env_marker_start__ = "*"
__env_marker_end__ = "*"
talk = "*shell:echo *MESSAGE*"
pyqwe uses load_dotenv()
from python-dotenv
to load the .env
file. You can change the name of the file to load, or
add multiple env files by setting the __env_files__
settings key.
[tool.pyqwe]
__env_files__ = [".env", ".env.local"]
talk = "*shell:echo *MESSAGE*"
This is the same as running load_dotenv(".env")
and load_dotenv(".env.local")
.
If you want to disable pyqwe from doing anything with environment variables, you can set the __env_ignore__
settings
key to true
.
[tool.pyqwe]
__env_ignore__ = true
talk = "*shell:echo {{MESSAGE}}"
This will disable the environment variable evaluation and loading of the .env
file, and result in {{MESSAGE}}
being
printed to the console in this case.