Skip to content

Commit

Permalink
fix dynamic table output when not on tty
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 31, 2017
1 parent da9a2b2 commit 3942f6f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions jiracli/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"syscall"
"text/template"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3942f6f

Please sign in to comment.