diecut.toml
The diecut.toml file at the root of your template directory configures metadata, variables, file handling, hooks, and the answers file.
[template]name = "rust-cli"version = "0.1.0"description = "A minimal Rust CLI application"
[variables.project_name]type = "string"prompt = "Project name"default = "my-cli"
[variables.license]type = "select"prompt = "License"choices = ["MIT", "Apache-2.0", "MIT OR Apache-2.0"]default = "MIT"
[files]exclude = ["*.pyc", ".DS_Store"]
[hooks]post_generate = ["hooks/post_generate.rhai"]
[answers]file = ".diecut-answers.toml"Summary
Section titled “Summary”| Key | Type | Default | Description |
|---|---|---|---|
| [template] | Template metadata | ||
name | string | required | Template name |
version | string | --- | Template version |
description | string | --- | Short description |
min_diecut_version | string | --- | Minimum diecut version required |
templates_suffix | string | ".tera" | File suffix that triggers template rendering |
| [variables.NAME] | Variable definitions | ||
type | enum | required | One of: string, bool, int, float, select, multiselect |
prompt | string | --- | Text shown to the user |
default | varies | --- | Default value |
choices | string[] | --- | Options for select/multiselect (required for those types) |
validation | string | --- | Regex pattern for input validation |
validation_message | string | --- | Message shown when validation fails |
when | string | --- | Tera expression; if false, variable is skipped |
computed | string | --- | Tera expression; value is derived, never prompted |
secret | bool | false | If true, value is not saved to answers file |
| [files] | File handling rules | ||
exclude | string[] | [] | Glob patterns to exclude from output |
copy_without_render | string[] | [] | Glob patterns to copy without Tera rendering |
conditional | object[] | [] | Conditional file inclusion rules |
| [files.conditional] items | |||
pattern | string | required | Glob pattern matching files |
when | string | required | Tera expression; if false, matched files are excluded |
| [hooks] | Hook scripts | ||
pre_generate | string[] | [] | Rhai scripts to run before generation |
post_generate | string[] | [] | Rhai scripts to run after generation |
| [answers] | Answers file config | ||
file | string | ".diecut-answers.toml" | Filename for answers file in generated project |
[template]
Section titled “[template]”Template metadata. Only name is required.
templates_suffix— Change from.terato something else if you prefer (e.g.,.j2,.tmpl). Files matching this suffix are rendered through the Tera engine; others are copied as-is.min_diecut_version— If set, diecut will refuse to process the template if the installed version is too old.
[variables]
Section titled “[variables]”Variables are prompted in declaration order. Each variable is a TOML table under [variables.NAME].
Key behaviors:
selectandmultiselectrequirechoicesto be set.computedvariables must not have aprompt. They are derived from other variables using Tera expressions.whencontrols conditional prompting. Uses Tera expression syntax (e.g.,"{{ use_ci }}"or just"use_ci").validationis a regex pattern. The entire input must match (anchored).secretvariables are prompted but excluded from.diecut-answers.toml.- Variables are available in templates as
{{ variable_name }}.
[variables.project_name]type = "string"prompt = "Project name"default = "my-project"validation = '^[a-z][a-z0-9_-]*$'validation_message = "Lowercase letters, numbers, hyphens, underscores only"
[variables.use_ci]type = "bool"prompt = "Set up CI?"default = true
[variables.ci_provider]type = "select"prompt = "CI provider"choices = ["github-actions", "gitlab-ci"]when = "{{ use_ci }}"
[variables.project_slug]type = "string"computed = "{{ project_name | slugify }}"[files]
Section titled “[files]”Control which files are included and how they’re processed.
exclude— Glob patterns. Matched files are not written to output. Useful for build artifacts, OS files.copy_without_render— Glob patterns. Matched files skip Tera rendering and are copied verbatim. Use for binaries, images, or files that contain{{ }}syntax that isn’t meant for Tera.conditional— Array of{ pattern, when }objects. Files matchingpatternare included only whenwhenevaluates to true.
[files]exclude = ["*.pyc", ".DS_Store", "__pycache__/**"]copy_without_render = ["assets/**/*.png", "fonts/**"]conditional = [ { pattern = ".github/**", when = "use_ci and ci_provider == 'github-actions'" }, { pattern = "src/cli.py*", when = "use_cli" },][hooks]
Section titled “[hooks]”Rhai scripts that run during generation. Paths are relative to the template root.
pre_generate— Run before files are rendered. Can abort generation withthrow.post_generate— Run after files are written. Has access tooutput_dir.
See Hooks reference for full documentation.
[answers]
Section titled “[answers]”Controls the answers file written into generated projects.
file— The filename. Default is.diecut-answers.toml. Set to""to disable.- The answers file stores the template source, version, and all non-secret variable values. It is used by
diecut updateto know how the project was generated.