gucci

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2016 License: MIT Imports: 9 Imported by: 0

README

Gucci

A simple cli templating tool written in golang. I created this because I wanted something that was more powerful than envsubt to use when templating files at Docker container start.

GitHub version License Build Status

Get

If you have go installed

go get github.com/noqcks/gucci

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

VERSION=0.0.1
wget -q https://github.com/noqcks/gucci/releases/download/v${VERSION}/gucci-v${VERSION}-darwin-amd64
chmod +x gucci-v${VERSION}-darwin-amd64
mv gucci-v${VERSION}-darwin-amd64 /usr/local/bin/gucci

Use

gucci can take input in multiple ways

file
$ gucci template.tpl > template.conf
stdin
$ gucci
Start typing stuff {{ print "here" }}
^d
Start typing stuff here

or via piping

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

Templating

Single ENV Var

This follows the same syntax as golang templating.

For example an ENV var $LOCALHOST = 127.0.0.1

gucci template.tpl > template.conf

# template.tpl
{{ .LOCALHOST }}

gucci template.tpl > template.conf -->

# template.conf
127.0.0.1

simple enough!

Iterative ENV Var

For iteration of ENV vars, you can set $BACKENDS=server1.com,server2.com

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

gucci template.tpl > template.conf -->

# template.conf
server server1.com
server server2.com
Functions

This is a list of all functions that you can use from inside your templates.

  • split: Used to split strings

    {{ split .BACKENDS "," }}
    
  • shell: For arbitrary shell commands

    {{ shell "cat VERSION.txt" }}
    

TODO

  • Return template output to template, but errs to terminal (not template)
  • Add a changelog for each release

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL