Skip to content

executable go-template command (like awk and jq!)

License

Notifications You must be signed in to change notification settings

Syuparn/tmplscript

Repository files navigation

tmplscript

GoTest MIT License

executable go-template command (like awk and jq!)

install

Get binary here.

You can also install from go install.

$ go install github.com/syuparn/tmplscript@latest

usage

$ go install github.com/syuparn/tmplscript@latest
$ echo "hello" | tmplscript '{{print . ", " "world!"}}'
hello, world!
# read from file instead
$ seq 15 | tmplscript -f example/fizzbuzz.tmpl
1
2
fizz
...

REPL mode

$ tmplscript -i
tmpl:1> {{add 2 3}}
5
tmpl:2> {{$i := "Hello"}}

tmpl:3> {{print $i ", world!"}}
Hello, world!
tmpl:4> ^C

In REPL mode, you can use histories and function autocompletes. See peterh/liner for details.

functions

Functions in Sprig are available.

(Of course template standard functions too!)

Also, you can use searchFunc to search defined functions and docFunc to check function's arguments.

$ tmplscript -i
tmpl:1> {{searchFunc "a"}}
[abbrev adler32sum atoi ago add1 add append abbrevboth]
tmpl:2> {{docFunc "atoi"}}
atoi string -> (int)

About

executable go-template command (like awk and jq!)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages