Agnostic and pluggable project generator for all kind of projects with a centralized repository. 100% written in Rust
Features:
- Variable substitution
- A centralized repository (updated content!)
- Custom repositories/folders (also private)
Usage: laguna [OPTIONS] TEMPLATENAME [TEMPLATEARGUMENTS]...
Options:
-r, --repository TEXT Repository (or folder) where templates are located.
-n, --name TEXT Project name (and name of the created folder)
-o, --output TEXT Folder where the project will be created (Defaults to
current folder)
-v, --verbose
-C, --no-clean Git repository will not be updated or cleaned up.
-c, --clean Force clean up of repository.
-h, --help Show this message and exit
Arguments:
TEMPLATENAME Name of the template.
TEMPLATEARGUMENTS
It will create a new folder in the output folder (current folder by default) with the directory tree of the template and rendered files with variable substitution.
Example: laguna kotlin-multiplatform --name newlaguna -- variable1=value1 variable2=value2
- Install docker
- Create an alias for an easy usage:
alias laguna="docker run terkitos/laguna "$@""
- Clone the project
- cd into the project
cargo install --path .
Creating a template is easy, the only things you need to do is to create a folder and within that folder you can already create your templates:
/tmp/laguna-templates
├── kotlin-multiplatform
└── test-template
In this case, in the folder laguna-templates
we have two templates, kotlin-multiplatform
and test-template
.
Now anything inside the template folder (in the example above it would be kotlin-multiplatform
or test-template
),
you can create any file/folder that you want. The folder structure will be copied and the (text) files will be rendered
accordingly.
An example of a template structure would be:
random-project
├── build.gradle.kts
├── settings.gradle.kts
├── src
│ └── com
| └── example
│ └── {{name|camel_case}}.kt
└── tst
From Tera
's readme: Tera is a template engine inspired by Jinja2 and the Django template language.
It has variables, functions and control flow statements. A hello world example:
@file:JvmName("{{name|camel_case}}")
package com.example
fun main(args: Array<String>) {
println("Hello world from {{name}}")
}
snake_case
: Transforms a string to snake_case. For example:my-project
will be translated tomy_project
camel_case
: Transforms a string to CamelCase. For example:my-project
will be translated toMyProject
mixed_case
: Transforms a string to mixedCase. For example:my-project
will be translated tomyProject
kebab_case
: Transforms a string to mixedCase. For example:My project
will be translated tomy-project
There are two places where you can learn more about templating:
- Laguna uses Tera as templating engine, its documentation is pretty good!
- Examples at the official laguna templates repository
- Checkout this project
- Run
cargo build