render and write out templated config files
Project description
write config files
This tool allows you to render templated config files and write them out.
This can be used to manage personal config files with different settings in different places (e.g. work/personal) or without committing secrets to a git repo.
getting started
You will need a file to configure the templates and a file to provide context
variables. By default these are names templates.yaml
and context.yaml
,
respectively. e.g:
templates
The root template directory is relative to the templates file. Each entry in the
template_groups
must be a group of templates that will be written to the
output directory. All template files must be listed explicitly.
Templates may be written to a different name than the name of the template file
by setting the destination
attribute. The written files may be made executable
by making is_executable
true.
e.g:
root_template_dir: ./templates
template_groups:
- output_dir: '~'
templates:
- template: .editorconfig
- template: .zshrc
- output_dir: ~/.config/
templates:
- template: git/config
- template: git/ignore
- output_dir: ~/.local/bin
templates:
- template: my_script.py
destination: my-script
is_executable: true
context
This will be parsed from YAML into a plain dictionary and used as the template context. A context file be provided. If no context is needed, make it an empty dict:
{}
usage
write
Render the templates and write the output files.
usage: write-config-files write [-h] [-t TEMPLATES] [-c CONTEXT] [-f] [-d]
options:
-h, --help show this help message and exit
-t TEMPLATES, --templates TEMPLATES
path to config file (default: templates.yaml)
-c CONTEXT, --context CONTEXT
path to context file (default: context.yaml)
-f, --force overwrite existing files
-d, --dry-run render templates but do not write files
diff
Show the diff between the current files and what would be written with write
.
usage: write-config-files diff [-h] [-t TEMPLATES] [-c CONTEXT] [-p PAGER]
options:
-h, --help show this help message and exit
-t TEMPLATES, --templates TEMPLATES
path to config file (default: templates.yaml)
-c CONTEXT, --context CONTEXT
path to context file (default: context.yaml)
-p PAGER, --pager PAGER
the pager to use to display each diff (default: no pager)
Project details
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 write_config_files-0.1.0.tar.gz
.
File metadata
- Download URL: write_config_files-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cc9b3628ed48bae8603996ef6086736abf5601b8de37bc631858e9a135406da |
|
MD5 | a999693d30d16b12ed3f04ecc3d40aed |
|
BLAKE2b-256 | 2647650b17a3671ffbe15b76b9bb1dd02dcab83a1c89d0360b5f5647c5a5f436 |
File details
Details for the file write_config_files-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: write_config_files-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b35fa2a3f2f8858f04e175ef327e5c9e8ae30f31f42e3c1980a3397229ebebc |
|
MD5 | eb8f28803e1974bc0bd93434fa25a7fd |
|
BLAKE2b-256 | aeb776e966346d48941b100a76c684d565e7b5d84168965690461786b5252233 |