From 8c7ca383f6467c2992f8fc9fddeb156c6e8b77c9 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Sun, 7 Jan 2018 10:49:00 -0800 Subject: [PATCH] [#139] add shellquote and toMinJson template functions --- jiracli/templates.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jiracli/templates.go b/jiracli/templates.go index 02e52c23..c6b727f0 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -8,8 +8,8 @@ import ( "io/ioutil" "os" "path/filepath" - "regexp" "reflect" + "regexp" "strconv" "strings" "text/template" @@ -17,6 +17,7 @@ import ( yaml "gopkg.in/coryb/yaml.v2" "github.com/coryb/figtree" + shellquote "github.com/kballard/go-shellquote" "github.com/mgutz/ansi" "golang.org/x/crypto/ssh/terminal" ) @@ -74,6 +75,16 @@ func TemplateProcessor() *template.Template { } return out }, + "shellquote": func(content string) string { + return shellquote.Join(content) + }, + "toMinJson": func(content interface{}) (string, error) { + bytes, err := json.Marshal(content) + if err != nil { + return "", err + } + return string(bytes), nil + }, "toJson": func(content interface{}) (string, error) { bytes, err := json.MarshalIndent(content, "", " ") if err != nil {