If you have heard of the cookiecutter
project, petridish
is a rust implementation of it.
| Feature | Description |
| ------------------------------- | ------------------------------------------------------------------------------------------------------ |
| Cross platform | Windows, Linux, MacOS |
| More flexible configuration | petridish
use yaml file to define the template variables |
| More humanized prompt | support different kinds of prompt (input
, choice
, multi choices
, confirm
) |
| Powerful template engine | we use tera
as our template engine, which is based on Jinja2/Django |
| One binary | one binary run everywhere |
Like cookiecutter
, you should provide directory structure like this:
Let's have a look at the petridish.yaml
file:
```yaml prompts: - name: name # normal input prompt message: what's your name
name: age # single choice prompt choices: [10, 20, 30] default: 20
name: hobby # multi choices prompt choices: [running, swimming] multi: true
name: is_geek # confirm prompt confirm: true
entrydir: "{{ reponame }}" # default is {{ reponame }} entrydirpromptmessage: repo dir name? ```
| Prompt kind | Field | Description | optional |
| --------------- | ----------- | --------------------------------------- | :------: |
| normal input
| name | templatevarname | |
| | message | prompt message | ✅ |
| | default | default value | ✅ |
| single choice
| name | templatevarname | |
| | message | prompt message | ✅ |
| | choices | choice items | |
| | default | default value | ✅ |
| multi choice
| name | templatevarname | |
| | message | prompt message | ✅ |
| | choices | choice items | |
| | default | default values | ✅ |
| | multi | must be true
or default
is provided | |
| confirm
| name | templatevarname | |
| | message | prompt message | ✅ |
| | default | default value (default false) | ✅ |
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:
More syntax details can be found in tera
.