project init (pi)
pi
is a command-line utility to initialize projects. It is written in rust.
It is intended to provide something like 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
. - 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.
- pi can initialize a git or mercurial repository inside your new project
Reasons to not use pi over cookiecutter:
- pi does not 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. It does not yet have custom keys.
Cool benchmarks (with Haskell's bench):
Tool | Language | Time (vim example plugin) | Time (rust library) |
---|---|---|---|
pi init | rust | 10.10 ms | 8.809 ms |
pi new | rust | 6.672 ms | 8.653 ms |
cookiecutter | python | 317.1 ms | 316.9 ms |
Installation
Binary releases
You can find binaries for x64 linux, ARM linux, and x64-windows on the release page.
Cargo
First, install cargo. Then:
Use
The easiest way to use pi is with the builtin templates:
For a custom template:
Note that you can put templates in $HOME/.pi_templates
and they can then be
called from anywhere.
For template examples, check out pi-templates.
Configuration
Global configuration is via the ~/.pi.toml
file. The following is an example:
= "BSD3"
= "git"
= "0.1.0"
[]
= "Vanessa McHale"
= "vamchale@gmail.com"
= "vmchale"
Project-specific config lives in $PROJECT_NAME/template.toml
. The following is
an example for a vim plugin:
= "BSD3"
= true
[]
= ["syntax/{{ project }}.vim","plugin/{{ project }}.vim","doc/{{ project }}.txt"] # blank files
= ["doc","syntax","plugin"]
= ["vimball.txt"] # files to be processed
[]
= "0.1.0"
= "git"
Templates
pi
uses mustache for templating, via the
rustache crate.
You can find examples and help on the mustache page.