# ๐ฆ duck-template
> A fast, customizable CLI tool for scaffolding project templates from structured JSON configurations.
`duck-template` lets you define reusable project templates in JSON and generate boilerplate code with ease using a simple, flexible command-line interface.
---
## โจ Features
- ๐งฑ **Template-based project scaffolding**
- โ๏ธ **Powerful `init` and `create` commands**
- ๐ฆ **JSON-based configuration support**
- ๐ชถ **Written in Rust โ lightweight and blazing fast**
- ๐ฌ **Helpful logging and error messages**
---
## ๐ฆ Installation
```bash
cargo install duck-template
````
---
## ๐ Usage
### Initialize a new project
```bash
duck-template init --name my-app
```
This will:
* Read your `duck-template.json` config
* Create a new output folder with the structure defined in the template
* Inject any CLI-provided values (e.g. `--name`) into the template
### Create a variant from your config
```bash
duck-template create --variant api
```
This will:
* Select a template variant defined in your config file
* Generate the corresponding output structure
---
## ๐งฉ Configuration
The CLI expects a JSON config file like this:
```json
{
"$schema": "https://zpgqhogoevbgpxustvmo.supabase.co/storage/v1/object/public/json/duck-template-schema.json",
"name": "my-template",
"version": "0.1.0",
"description": "A customizable web app starter template.",
"outdir": "./output",
"variants": [
{
"name": "api",
"description": "Basic Express API setup",
"files": [
{ "path": "src/index.ts", "content": "console.log('API running');" },
{ "path": "tsconfig.json", "template": "tsconfig-template.json" }
]
}
]
}
```
You can define:
* `variants`: groups of files or folders
* `outdir`: where the output should be created
* `template`: reuse external files and inject dynamic variables
---
## ๐งช Example
```bash
duck-template init --name wiseman
```
```json
// duck-template.json
{
"name": "wiseman",
"outdir": "./output",
"variants": [
{
"name": "wiseman",
"files": [
{ "path": "src/main.ts", "content": "console.log('{{name}} is wise');" }
]
}
]
}
```
Results in:
```
output/
โโโ src/
โโโ main.ts // => console.log("wiseman is wise");
```
---
## ๐ Commands
| `init` | Initializes a new template project |
| `create` | Generates output from a defined variant |
| `help` | Shows the help menu |
| `version` | Prints the CLI version |
---
## ๐ License
Licensed under either of:
* MIT License
* Apache License, Version 2.0
---
## ๐ฌ Feedback / Contributions
Feel free to open issues, request features, or contribute via pull requests.
---
> ๐ฆ **duck-template** โ because smart devs don't start from scratch every time.