| Crates.io | duck-template |
| lib.rs | duck-template |
| version | 0.1.8 |
| created_at | 2025-08-06 20:02:58.255789+00 |
| updated_at | 2025-08-11 07:06:05.012788+00 |
| description | A cli tool for generating files from a template just with a json file |
| homepage | |
| repository | https://github.com/gentleeduck/duck-template |
| max_upload_size | |
| id | 1784268 |
| size | 1,600,971 |
Fast, customizable Rust-powered project scaffolding β because smart devs donβt start from scratch.
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 complete control over how projects and files are created.
api, web, cli, etc.)init, create, and create-variantcargo install duck-template
duck-template init --name my-app
This will:
my-app/duck-template.jsonduck-template create --variant api --config ./duck-template.json
With a remote config:
duck-template create --variant api --config https://example.com/template.json
With extra arguments:
duck-template create \
--variant cli \
--config ./template.json \
--outdir ./output \
--args author=Ahmed,year=2025
duck-template create-variant \
--source ./template-source \
--name cli \
--description "Command-line app setup" \
--config ./duck-template.json
This will:
Templates are defined in a duck-template.json file:
{
"$schema": "https://zpgqhogoevbgpxustvmo.supabase.co/storage/v1/object/public/json/duck-template-schema.json",
"name": "my-template",
"version": "1.0.0",
"description": "Reusable project setup",
"outdir": "./output",
"args": {
"author": "Anonymous",
"license": "MIT"
},
"variants": [
{
"name": "api",
"description": "Express API starter",
"files": [
{ "path": "src/index.ts", "content": "console.log('API ready');" },
{ "path": "tsconfig.json", "template": "tsconfig-template.json" }
]
}
]
}
init β Create a New Project Directoryduck-template init --name my-app
| Flag | Description |
|---|---|
-n, --name |
Project name (used for folder name and inside templates). |
create β Generate Files from a Variantduck-template create --variant api --config ./config.json
| Flag | Description |
|---|---|
-v, --variant |
Name of the variant to generate |
-d, --outdir |
Output directory (defaults to ./) |
-c, --config |
Local or remote JSON config |
-a, --args |
Key=value overrides for template variables (author=Ahmed) |
create-variant β Package a Folder into a Variantduck-template create-variant \
--source ./starter \
--name basic \
--description "Basic setup" \
--config ./duck-template.json
| Flag | Description |
|---|---|
-s, --source |
Source directory or file |
-n, --name |
Unique name for the variant |
-d, --description |
Short description of the variant |
-c, --config |
Optional path to an existing config to update |
Given:
duck-template init --name wiseman
With config:
{
"name": "wiseman",
"outdir": "./output",
"variants": [
{
"name": "wiseman",
"files": [
{ "path": "src/main.ts", "content": "console.log('{{name}} is wise');" }
]
}
]
}
Result:
output/
βββ src/
βββ main.ts // console.log("wiseman is wise");
duck-template --help
duck-template --version
Also works with subcommands:
duck-template init --help
duck-template create-variant --help
Pull requests, issues, and suggestions are welcome! Fork, tweak, and share your own templates.
π¦ duck-template β smart scaffolding for smart developers.