Templates allow you to interpolate values from Flags, Arguments and Configuration into some aspects of commands.

For example the exec command type allows you to use templates to put arguments into the command being run.

We use the Go template language at the moment, it’s not the best we might look at something else later.

Only some fields are parsed through templates, the documentation for each command type will call out what is supported.


An example template use was shown in the exec documentation:

command: |
            {{ default .Config.Cowsay "cowsay" }} "{{ .Arguments.message | escape }}"

Here we have examples of accessing the .Config and .Arguments structures and using some functions.

Available Data

.ConfigData stored in the configuration file for this application
.ArgumentsData supplied by users using command arguments
.FlagsData supplied by users using command flags

Available Functions

requireAsserts that some data is available, errors with an optional custom message on failure{{ require .Config.Password "Password not set in the configuration" }}
escapeEscapes a string for use in shell arguments{{ escape .Arguments.message }}
read_fileReads a file{{ read_file .Arguments.file }}
defaultChecks a value, if its not supplied uses a default{{ default .Config.Cowsay "cowsay" }}