execute-template command executes one or more templates and writes the output to stdout. This is useful for testing templates and template functions.
Usage
Description
Theexecute-template command evaluates templates with access to all template data and functions available in chezmoi, including:
- Configuration data (
.variables) - Template functions (
lookupSecret,output, etc.) - Chezmoi metadata (
.chezmoi.*variables)
--file).
Flags
Treat arguments as filenames containing templates rather than template strings.
Simulate
chezmoi init mode, which provides access to init-specific template functions like promptString, promptBool, etc.Set the left template delimiter.
Set the right template delimiter.
Simulate
promptString responses. Format: prompt=value. Can be specified multiple times.Simulate
promptBool responses. Format: prompt=true|false. Can be specified multiple times.Simulate
promptInt responses. Format: prompt=123. Can be specified multiple times.Simulate
promptChoice responses. Format: prompt=choice. Can be specified multiple times.Simulate
promptMultichoice responses. Format: prompt=choice1/choice2. Can be specified multiple times.Simulate
stdinIsATTY returning true.Set
.chezmoi.stdin to the contents of stdin.Examples
Execute a simple template string
Access configuration data
Test template functions
Execute a template file
Read template from stdin
Test init templates with prompts
Use custom delimiters
Execute multiple templates
Access stdin in templates
Template Testing
Test conditionals
Test loops
Test secret managers
Debug template data
Init Template Testing
Test your.chezmoi.toml.tmpl configuration template: