feat: add defaultColWidth template function

This function can be used in templates to change the default column
width to accommodate wider terminals.
This commit is contained in:
Max Jonas Werner
2021-08-09 13:15:32 +02:00
parent a59fdc81fc
commit 80adab38ee
+4
View File
@@ -263,6 +263,10 @@ func RunTemplate(templateName string, data interface{}, out io.Writer) error {
headers := []string{} headers := []string{}
cells := [][]string{} cells := [][]string{}
tmpl, err := TemplateProcessor().Funcs(map[string]interface{}{ tmpl, err := TemplateProcessor().Funcs(map[string]interface{}{
"defaultColWidth": func(cw int) string {
table.SetColWidth(cw)
return ""
},
"headers": func(titles ...string) string { "headers": func(titles ...string) string {
headers = append(headers, titles...) headers = append(headers, titles...)
return "" return ""