Tera CLI

Codefresh build status Crates.io License: MIT

Tera CLI for one-off template interpolation from context file / env vars.

The following context formats are supported:

Simple Examples

TOML

Template template.tmpl

jinja {% if c.hello %}{{ c.msg }}{% endif %}

TOML .tera.toml

toml hello = true msg = "Hello World!"

STDOUT

```bash

tera -f template.tmpl --toml . Hello World!

cat template.tmpl | tera --toml . Hello World!

tera -s "$(cat template.tmpl)" --toml . Hello World! ```

Environment Variables

Template template.tmpl

jinja {% if c.MSG %}{{ c.MSG }}{% endif %}

STDOUT

```bash

MSG="Hello World!" tera -f template.tmpl --env Hello World! ```

By default, setting --toml . looks for .tera.toml context file in current working directory. Similarly, setting --json . looks for .tera.json in current working directory. Use --toml file_to_toml to change the path to the context file.

Also, the parsed value from any of the context type (i.e. TOML / JSON / env vars) is stored into c as root key in the Tera context. If you wish to change the root key to say conf, use -r conf to override.

For more details, run

bash tera --help

Acknowledgement

Thanks to original Tera author, whose GitHub repository is at: https://github.com/Keats/tera.