fix dynamic table output when not on tty

This commit is contained in:
Cory Bennett
2017-08-31 16:00:45 -07:00
parent da9a2b2b90
commit 3942f6f5d6
+10 -3
View File
@@ -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
}
return w
if os.Getenv("COLUMNS") != "" {
w, err = strconv.Atoi(os.Getenv("COLUMNS"))
}
if err == nil {
return w
}
return 120
},
"sub": func(a, b int) int {
return a - b