From 3942f6f5d6b1f8bf44fd79e9ab5e794a1c130e40 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Thu, 31 Aug 2017 16:00:45 -0700 Subject: [PATCH] fix dynamic table output when not on tty --- jiracli/templates.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jiracli/templates.go b/jiracli/templates.go index 15e3efab..aef62c3a 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "reflect" + "strconv" "strings" "syscall" "text/template" @@ -69,10 +70,16 @@ func TemplateProcessor() *template.Template { }, "termWidth": func() int { w, _, err := terminal.GetSize(syscall.Stdout) - if err != nil { - return 80 + if err == nil { + return w + } + if os.Getenv("COLUMNS") != "" { + w, err = strconv.Atoi(os.Getenv("COLUMNS")) + } + if err == nil { + return w } - return w + return 120 }, "sub": func(a, b int) int { return a - b