This is experimental and the API is likely to change
t8
is a simple CLI application that renders templates defined on Github (and other locations).
Inspired by giter8.
Install using Go
go get github.com/steinfletcher/t8/cmd/t8
Or download a prebuilt binary from github releases.
- A scaffolding tool for generating boilerplate applications (like Yeoman or sbt minus the build step)
- Generator for microservice applications for consistency and speed
- Automate generation of config files
- Uses Go templating
- Define config as HCL or YAML
- Interactive CLI to prompt for parameters
- Pass input parameters as arguments (useful in CI)
- Use sprig functions in templates
$ t8 new https://github.com/myOrg/myTemplate my-amazing-app
Enter the required parameters to generate "My Amazing App".
project name[acme]: My amazing app
go version[1.12]:
Template created: /home/stein/code/my-amazing-app
$ t8 -ProjectName=acme -GoVersion=1.12 https://github.com/org/go-echo-template.t8 my-amazing-app
Template created: /home/stein/code/my-amazing-app
Create a Go template and host it on github. Create a file called t8.hcl
or t8.yml
in the root of the project. This is the configuration file where you can configure your generator.
t8
uses Go's standard templating support. It adds some useful template functions via sprig, which allows you to manipulate the parameters
Hello {{ .Parameter.Name | lower | snakecase }}
A parameter
is a variable set at runtime and is made accessible to your Go template. You can also define defaults
parameter "ProjectName" {
type = "string"
description = "the project name"
default = "acme"
}
In this example the user will be prompted to enter the project name or provide it as a command line flag. If the user does not define this variable the default value is used.
string
- the default type.
option
- presents an option list to the user. Example
parameter "SqlDialect" {
type = "option"
description = "the SQL dialect"
default = [
"postgresql",
"mysql",
]
}
You can exclude the generation of files and directories using the excludePath
variable.
excludePath "Scripts" {
paths = [
"test.sh",
]
}
This configures an unconditional exclusion on a path pattern - the test.sh
file will be excluded from the final generated content. You can also exclude paths based on the value of a parameter.
excludePath "Postgres" {
paths = [
"^/postgres/.*$"
]
parameterName = "SqlDialect"
operator = "notEqual"
parameterValue = "postgresql"
}
In this example, the /postgres
directory will not be generated if the SqlDialect
parameter is not equal to postgresql
. The available operators are equal
and notEqual