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.4.0.tar.gz
.
File metadata
- Download URL: write_config_files-0.4.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55bfb235a474c83dd17d18485bd9fcb5d5cb5bf82a011f36eb48af722e539452 |
|
MD5 | ecd6d0e56d136872834a00a0a56ceecc |
|
BLAKE2b-256 | dfc9274524c5923335d2ce54bae42f9c30904a9e23f29eff829e7fd37a51ad86 |
File details
Details for the file write_config_files-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: write_config_files-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cb3f850aa4eafc834f84e3a7b2209ab5008b8b38c5379cac6af68850577d3a8 |
|
MD5 | cd93cb9062e965893a065286490792ea |
|
BLAKE2b-256 | 3754a0d78d727450f26461264592704664f443130e8f89db170a94ee470d3c29 |