From 027adeef46999466d36e8f875263e8e411d0030c Mon Sep 17 00:00:00 2001 From: Adriano Date: Mon, 18 Mar 2019 08:39:38 -0400 Subject: [PATCH] Add 'pctOf' and 'fit' template functions --- jiracli/templates.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jiracli/templates.go b/jiracli/templates.go index 78d571ce..1224a3ed 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -76,6 +76,9 @@ func TemplateProcessor() *template.Template { } return out }, + "fit": func(size int, content string) string { + return fmt.Sprintf(fmt.Sprintf("%%-%d.%ds", size, size), content) + }, "shellquote": func(content string) string { return shellquote.Join(content) }, @@ -106,6 +109,9 @@ func TemplateProcessor() *template.Template { } return 120 }, + "pctOf": func(size, percent int) int { + return int(float32(size) * (float32(percent) / 100)) + }, "sub": func(a, b int) int { return a - b }, @@ -354,7 +360,7 @@ const defaultEditTemplate = `{{/* edit template */ -}} # issue: {{ .key }} - created: {{ .fields.created | age}} ago update: comment: - - add: + - add: body: |~ {{ or .overrides.comment "" | indent 10 }} fields: @@ -484,7 +490,7 @@ const defaultTransitionTemplate = `{{/* transition template */ -}} {{- if .meta.fields.comment }} update: comment: - - add: + - add: body: |~ {{ or .overrides.comment "" | indent 10 }} {{- end -}}