tmplscript

command module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 15 Imported by: 0

README

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)

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