Using Templates
Template sources
Section titled “Template sources”diecut pulls templates from local paths or any Git host.
| Source | Example |
|---|---|
| Local path | diecut new ./my-template |
| GitHub | diecut new gh:user/repo |
| GitLab | diecut new gl:user/repo |
| Codeberg | diecut new cb:user/repo |
| Any Git URL | diecut new https://git.example.com/repo.git |
Git templates are cached at ~/.cache/diecut/templates/. Override with DIECUT_CACHE_DIR.
Multi-template repos (subpaths)
Section titled “Multi-template repos (subpaths)”A single repo can hold multiple templates in subdirectories. Add the subdirectory path after the repo:
diecut new gh:raiderrobert/diecut-templates/python-pkg --output my-projectdiecut new gh:raiderrobert/diecut-templates/rust-cli --output my-clidiecut clones the repo once and navigates to the specified subdirectory.
Overriding variables
Section titled “Overriding variables”Pass -d key=value to skip prompts for specific variables:
diecut new gh:user/template -d project_name=foo -d license=MIT -o my-projectVariables passed with -d skip the interactive prompt. You can mix — pass some via -d and diecut prompts for the rest.
Non-interactive mode
Section titled “Non-interactive mode”For CI pipelines or scripting, use --defaults:
diecut new gh:user/template --defaults -o my-projectEvery variable uses its default value. No prompts. Combine with -d to override specific ones:
diecut new gh:user/template --defaults -d project_name=ci-test -o outputDry run
Section titled “Dry run”Preview what would be generated without writing any files:
diecut new ./my-template --dry-runAdd --verbose to also see the rendered file contents:
diecut new ./my-template --dry-run --verboseManaging the cache
Section titled “Managing the cache”List cached templates:
diecut listTemplates live at ~/.cache/diecut/templates/. Set DIECUT_CACHE_DIR to change the location. Delete the directory to clear the cache.