Skip to content

crosseyed/prjstart

Repository files navigation

Github Actions Go Report Card License

Project Start - prjstart

Project Start prjstart is a cli tool to start a project using template boilerplates.

Quickstart

Add a set of variables that will be used in your project. Variables are stored in ~/.env. All the variables defined here are passed to templates along with all environment variables as .Env.$VARIABLE

~/.env

AUTHOR=First Last <first.last@somedomain.com>

Create a project that will be used as an example to generate go projects. Templates are rendered using Go's text/template

mkdir -p ~/prjs/prjgo

~/prjs/prjgo/AUTHORS

# prj:render <--- This modeline tells prjstart to render file as a template. Line is stripped out from output file.
{{.Env.AUTHOR}}

~/prjs/prjgo/README.md

# prj:render
# {{.Project.NAME}}

~/prjs/prjgo/.gitignore

# Vim
.*.swp

# Mac
.DS_Store

/vendor/

Add a binary

mkdir -p ~/prjs/prjgo/cmd/\{\{.Project.NAME\}\}
touch ~/prjs/prjgo/cmd/\{\{.Project.NAME\}\}/main.go 

~/prjs/prjgo/cmd/\{\{.Project.NAME\}\}/main.go

// prj:render
package main

import "fmt"

func main() {
    fmt.Println("Project {{.Project.NAME}}")
}

Add the following file ~/.prjstart.yml

templates:
    - name: goproject
      url: ~/prjs/prjgo

Create the project using go

prjstart start goproject ~/mynewproject

Git templates

cd ~/prjs/prjgo
git init
git add .
git commit -m "first commit"
git push --set-upstream git@github.com/owner/prjgo.git master

Modify ~/.prjstart.yml

templates:
    - name: goproject
      url: http://github.com/owner/prjgo.git

Start a new project with the recently checked in boilerplate

prjstart start goproject ~/myproject

Variables

Variables are either environment variables, variables defined in ~/.env or project variables.

To list available project variables run

prjstart list --vars