$ text-template-cli example1.txt.tmpl
USER: takeshi
FOO: <no value>
BAR: <no value>
BAZ:
An environment variable USER is used to render.
$ text-template-cli example1.txt.tmpl dummy.env >output.txt
$ cat output.txt
USER: takeshi
FOO: foo_from_env
BAR: bar_from_env
BAZ:
$ text-template-cli example1.txt.tmpl dummy.env
USER: takeshi
FOO: foo_from_env
BAR: bar_from_env
BAZ:
$ text-template-cli example1.txt.tmpl dummy.json
USER: takeshi
FOO: foo_from_json
BAR: <no value>
BAZ:
- baz1
- baz2
$ text-template-cli example1.txt.tmpl dummy.yaml
USER: takeshi
FOO: foo_from_yaml
BAR: <no value>
BAZ:
QUX.FOO: [baz1 baz2]
$ text-template-cli example1.txt.tmpl dummy.env dummy.json
Overwriting FOO: foo_from_env -> foo_from_json by dummy.json
USER: takeshi
FOO: foo_from_json
BAR: bar_from_env
BAZ:
- baz1
- baz2
$ text-template-cli example1.txt.tmpl dummy.env dummy.json dummy.yaml
Overwriting FOO: foo_from_env -> foo_from_json by dummy.json
Overwriting FOO: foo_from_json -> foo_from_yaml by dummy.yaml
USER: takeshi
FOO: foo_from_yaml
BAR: bar_from_env
BAZ:
- baz1
- baz2
QUX.FOO: [baz1 baz2]
Use redirection for stderr to /dev/null or somewhere.
$ text-template-cli example1.txt.tmpl dummy.env dummy.json dummy.yaml 2>/dev/null
USER: takeshi
FOO: foo_from_yaml
BAR: bar_from_env
BAZ:
- baz1
- baz2
QUX.FOO: [baz1 baz2]
Use functions default, contains, lower and ternary from sprig.
$ text-template-cli sprig.tmpl dummy.env
FOO: foo_from_env
FOO is from ENV
$ text-template-cli sprig.tmpl dummy.json
FOO: foo_from_json
FOO is not from ENV
$ TITLE=Example1 text-template-cli dir-example1/source --output-directory dir-example1/output
This command will render all files in the directory dir-example1/source and output to the directory dir-example1/output.
$ TITLE=Example2 text-template-cli dir-example1/source/dir1/README.md.tmpl --output-directory dir-example1/output
This command will render the file dir-example1/source/dir1/README.md.tmpl and output to the file dir-example1/output/README.md.
text-template-cli dir-example1/source/dir2/simple1.txt --output-directory dir-example1/output
This command will copy the file dir-example1/source/dir2/simple1.txt and output to the file dir-example1/output/simple1.txt.