petridish

CI Version info GitHub
A command-line utility that creates project structure.

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 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 |

Usage

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

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) | ✅ |

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:

More syntax details can be found in tera.