Very simple standalone cli templating
Branch: master
Clone or download
Latest commit e90dfaf Feb 14, 2019


A simple CLI templating tool written in golang.

GitHub version License Build Status


If you have go installed:

$ go get

Or you can just download the binary and move it into your PATH:

wget -q${VERSION}/gucci-v${VERSION}-darwin-amd64
chmod +x gucci-v${VERSION}-darwin-amd64
mv gucci-v${VERSION}-darwin-amd64 /usr/local/bin/gucci


Locating Templates

gucci can locate a template in multiple ways.


Pass the template file path as the first argument:

$ gucci template.tpl > template.out


Supply the template through standard input:

$ gucci
Start typing stuff {{ print "here" }}
Start typing stuff here

Via piping:

$ echo '{{ html "<escape-me/>" }}' | gucci

Supplying Variable Inputs

gucci can receive variables for use in templates in the following ways (in order of lowest to highest precedence):

  • A JSON or YAML file
  • Environment variables
  • Variable command options

Variables File

Given an example variables file:

# vars.yaml
  - name: bastion
  - name: app

Pass it into gucci with -f or --vars-file:

$ gucci -f vars.yaml template.tpl

Environment Variables

Here, MY_HOST is available to the template:

$ export MY_HOST=localhost
$ gucci template.tpl

Variable Options

Pass variable options into gucci with -s or --set-var, which can be repeated:

$ gucci -s template.tpl

Variable option keys are split on the . character, and nested such that the above example would equate to the following yaml variable input:

  bar: baz


GoLang Functions

All of the existing golang templating functions are available for use.

Sprig Functions

gucci ships with the sprig templating functions library offering a wide variety of template helpers. Sprig's env and expandenv functions are disabled in favor of gucci's own environment variable parsing (see below).

Built In Functions

Furthermore, this tool also includes custom functions:

  • shell: For arbitrary shell commands

    {{ shell "cat VERSION.txt" }}


NOTE: gucci reads and makes available all environment variables.

For example a var $LOCALHOST =

gucci template.tpl > template.conf

# template.tpl

gucci template.tpl > template.conf -->

# template.conf

simple enough!

For an iteration example, you have $,

# template.tpl
{{ range split .BACKENDS "," }}
server {{ . }}
{{ end }}

gucci template.tpl > template.conf -->

# template.conf



go get
go get
go get

Run tests:

ginkgo ./...