petridish
If you have heard of the cookiecutter project, petridish is a rust implementation of it.
Features
| Feature | Description |
|---|---|
| Cross platform | Windows, Linux, MacOS |
| More flexible configuration | petridish use toml file to define the template variables |
| More humanized prompt | support different kinds of prompt (input, select, multi select, confirm) |
| Powerful template engine | we use tera as our template engine, which is based on Jinja2/Django |
| One binary | one binary run everywhere |
| Manage cached templates | If you download a remote template, it will be cached, so later you can just use its name without download it again. You can also list or remove these cached templates |
Usage
Like cookiecutter, you should provide directory structure like this:

Let's have a look at the petridish.toml file:
[]
= "project name?"
= "project_name"
= "This is an awesome template"
[[]]
= "name"
= "what's your name"
= "string"
[[]]
= "age"
= [10, 20, 30]
= 20
= "number"
[[]]
= "hobby"
= ["running", "swimming"]
= true
= "string"
[[]]
= "is_geek"
= "bool"
= true
Petridish config
| Field | Description | optional |
|---|---|---|
| project_prompt | the prompt message for project_var_name, default is project name? |
✅ |
| project_var_name | the project var name, default is project_name |
✅ |
| short_description | the short description of the template, will show in sub cmd list |
✅ |
| long_description | the long description of the template, will show before first prompt (support Markdown highlight) | ✅ |
Prompt config
| Prompt kind | Field | Description | optional |
|---|---|---|---|
| string input | name | template var name | |
| prompt | prompt message | ✅ | |
| default | default "", support template render | ✅ | |
| regex | regex pattern, the prompt value must match the pattern | ✅ | |
| type | must be string |
||
| number input | name | template var name | |
| prompt | prompt message | ✅ | |
| default | default 0 | ✅ | |
| min | the min value | ✅ | |
| max | the max value | ✅ | |
| type | must be number |
||
| select | name | template var name | |
| prompt | prompt message | ✅ | |
| choices | choice items | ||
| default | default value | ✅ | |
| type | string or number |
||
| multi select | name | template var name | |
| prompt | prompt message | ✅ | |
| choices | choice items | ||
| default | default values | ✅ | |
| multi | must be true |
||
| emptyable | whether value can be empty, default false |
✅ | |
| type | string or number |
||
| confirm | name | template var name | |
| prompt | prompt message | ✅ | |
| default | default value (default false) |
✅ | |
| type | must be bool |
Remote git abbreviations
petridish knows abbreviations for Github(gh) and GitLab(gl) projects
The format should be like <abbreviation>[+<protocol>]:<namespace>/<project>
protocol can be: https, http, ssh, (default is https)
If the remote http(s) project is private, petridish will prompt to ask username and password for authorization.
Demo

Template
A Tera template is just a text file where variables and expressions get replaced with values when it is rendered. The syntax is based on Jinja2 and Django templates.
There are 3 kinds of delimiters and those cannot be changed:
- {{ and }} for expressions
- {% and %} for statements
- {# and #} for comments
More syntax details can be found in tera.