π¦ duck-template
Generate and manage project templates with ease β fast, customizable, and powered by Rust.
duck-template helps you scaffold and manage projects using structured JSON configurations and flexible CLI commands. With variant support, remote configs, and dynamic flag injection, it gives you full control over how projects and their files are created.
β¨ Features
- π§± Template-based project scaffolding with JSON
- ποΈ Variants to support different project layouts (e.g.,
api,web,cli) - π Remote or local config support (pass a URL or file path)
- π§ Unified flag parsing with dynamic injection into templates
- πͺΆ Blazing fast β written in Rust
- π¦ Modular commands:
init,create, andcreate-variant
π¦ Installation
π Quick Start
π§ Initialize a New Project
This will:
- Create a directory
my-app/ - Inject the name into templated files
- Use your local
duck-template.jsonfile
ποΈ Create From a Variant
Or use a remote config:
Optional extras:
β¨ Create a New Variant
This will:
- Package the folder into a new variant
- Append it to the config (if valid and writable)
π§© Configuration Format
You define templates in a duck-template.json file like this:
π οΈ Command Reference
π§ init
Create a new project directory.
| Flag | Description |
|---|---|
-n, --name |
Name of the project. Used for the folder name and inside templates. |
ποΈ create
Generate files from a predefined variant.
| Flag | Description |
|---|---|
-v, --variant |
Name of the variant to generate |
-d, --outdir |
Directory to write output (defaults to ./) |
-c, --config |
Local or remote JSON config file |
-a, --args |
Key=value overrides for template injection (e.g., author=Ahmed) |
π§ͺ create-variant
Package a folder into a new variant.
| Flag | Description |
|---|---|
-s, --source |
Source directory or file |
-n, --name |
Unique name for the variant |
-d, --description |
Short explanation of what this variant is for |
-c, --config |
Optional path to update an existing config file |
π Output Example
Given:
And this config:
The result will be:
output/
βββ src/
βββ main.ts // console.log("wiseman is wise");
π¬ Help & Version
Also works with subcommands like:
π Contributions
Pull requests, issues, and suggestions are welcome! Feel free to fork, tweak, and share your own templates too.
π¦ duck-template β because smart devs donβt start from scratch.