project init (pi)
This is a command-line utility written in rust that initializes projects based on templates. It is intended to provide something similar to cookiecutter, but faster.
Reasons to use pi:
- You want to automate the process of starting a new project, in a language-agnostic way.
- You want project initialization that's quick
Reasons to use pi over cookiecutter:
- Templates are smaller. Define files you need in a
.toml
rather than an entire directory tree. - Fast. pi 30x faster than cookiecutter when rendering the sample vim plugin template.
- pi uses mustache, a logic-less language that has libraries for many other languages. That means that you can manipulate your pi templates in other languages.
- pi can initialize a git or mercurial repository inside your new project
Reasons to not use pi over cookiecutter:
- pi does not (currently) fetch templates remotely.
- pi uses logic-less templates, which are not as sophisticated as the jinja templates that cookiecutter uses.
- pi is a work in progress. This might mean you run into some bugs.
Cool benchmarks (with Haskell's bench):
Tool | Language | Time (vim example plugin) | Time (rust library) |
---|---|---|---|
pi | Rust | 10.10 ms | 8.809 ms |
cookiecutter | Python | 317.1 ms | 316.9 ms |
Installation
Binary releases
You can find binaries on the release page. Unfortunately, I can only create binaries for x64 linux, ARM linux, and 64-bit Windows at this time.
Cargo
First, install cargo. Then type:
and cargo will install pi for you.
Use
For use examples, check out examples/vim-plugin
Configuration
Configuration is via the ~/.pi.toml
file. The following is an example:
[]
= ["syntax/{{ project }}.vim","plugin/{{ project }}.vim","doc/{{ project }}.txt"]
= ["doc","syntax","plugin"]
= ["LICENSE","README.md","vimball.txt"]
[]
= "0.1.0"
= "git"
You can also set your defaults (e.g. name, email) in ~/.pi.toml
. The following is an example:
This says your preferred version control is git
, and sets your name & email.
Templates
pi
uses mustache for templating, via the
rustache crate.
You can find examples and help on the mustache page.