Skip to content

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"
KeyTypeDefaultDescription
[template]Template metadata
namestringrequiredTemplate name
versionstring---Template version
descriptionstring---Short description
min_diecut_versionstring---Minimum diecut version required
templates_suffixstring".tera"File suffix that triggers template rendering
[variables.NAME]Variable definitions
typeenumrequiredOne of: string, bool, int, float, select, multiselect
promptstring---Text shown to the user
defaultvaries---Default value
choicesstring[]---Options for select/multiselect (required for those types)
validationstring---Regex pattern for input validation
validation_messagestring---Message shown when validation fails
whenstring---Tera expression; if false, variable is skipped
computedstring---Tera expression; value is derived, never prompted
secretboolfalseIf true, value is not saved to answers file
[files]File handling rules
excludestring[][]Glob patterns to exclude from output
copy_without_renderstring[][]Glob patterns to copy without Tera rendering
conditionalobject[][]Conditional file inclusion rules
[files.conditional] items
patternstringrequiredGlob pattern matching files
whenstringrequiredTera expression; if false, matched files are excluded
[hooks]Hook scripts
pre_generatestring[][]Rhai scripts to run before generation
post_generatestring[][]Rhai scripts to run after generation
[answers]Answers file config
filestring".diecut-answers.toml"Filename for answers file in generated project

Template metadata. Only name is required.

  • templates_suffix — Change from .tera to 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 are prompted in declaration order. Each variable is a TOML table under [variables.NAME].

Key behaviors:

  • select and multiselect require choices to be set.
  • computed variables must not have a prompt. They are derived from other variables using Tera expressions.
  • when controls conditional prompting. Uses Tera expression syntax (e.g., "{{ use_ci }}" or just "use_ci").
  • validation is a regex pattern. The entire input must match (anchored).
  • secret variables 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 }}"

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 matching pattern are included only when when evaluates 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" },
]

Rhai scripts that run during generation. Paths are relative to the template root.

  • pre_generate — Run before files are rendered. Can abort generation with throw.
  • post_generate — Run after files are written. Has access to output_dir.

See Hooks reference for full documentation.

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 update to know how the project was generated.