summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-30 14:03:30 -0500
committerJeff Carr <[email protected]>2025-10-30 14:03:30 -0500
commit357b464107b520fae4ed064b3dac639b14105e1a (patch)
tree78785aa9dec34de85392363acd29a37abe6fdb32
parent57fa0dc00c8141c252c8ec452f8a34448315c33d (diff)
wasn't cleaning out newlines in row dataHEADv0.0.34v0.0.33masterdevel
-rw-r--r--humanTable.go8
-rw-r--r--tablePB.go35
-rw-r--r--time.string.go3
3 files changed, 32 insertions, 14 deletions
diff --git a/humanTable.go b/humanTable.go
index 17b84a1..caf0bba 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -30,7 +30,7 @@ func StandardTableRow(sizes []int, args []string) (string, string) {
}
fmts = append(fmts, sfmt)
if len(args) > i {
- val := args[i]
+ val := strings.Join(strings.Fields(args[i]), " ") // removes all newlines
cell = fmt.Sprintf(sfmt, val)
parts = append(parts, cell)
} else {
@@ -52,7 +52,8 @@ func StandardTableRow(sizes []int, args []string) (string, string) {
// small = 0
// }
}
- return line[0:small], strings.Join(fmts, " ")
+ smalls := fmt.Sprintf("small=%d", small)
+ return line[0:small], strings.Join(fmts, " ") + " " + smalls
}
func StandardTableRowDebug(sizes []int, args []string) (string, string) {
@@ -62,7 +63,8 @@ func StandardTableRowDebug(sizes []int, args []string) (string, string) {
// cell = fmt.Sprintf(sfmt, val)
}
}
- return StandardTableRow(sizes, args)
+ line, fmts := StandardTableRow(sizes, args)
+ return line, fmts
}
/*
diff --git a/tablePB.go b/tablePB.go
index edfaacb..7272f01 100644
--- a/tablePB.go
+++ b/tablePB.go
@@ -13,17 +13,21 @@ import (
)
func PrintTable(pb *guipb.Table) {
- PrintTableLimit(pb, -1)
+ PrintTableLimit(pb, -1, false)
+}
+
+func PrintTableDebug(pb *guipb.Table) {
+ PrintTableLimit(pb, -1, true)
}
// limits the number of out lines
-func PrintTableLimit(pb *guipb.Table, limit int) {
- // fmt.Info("print PB here")
+func PrintTableLimit(pb *guipb.Table, limit int, debug bool) {
+ // fmt.Println("print PB here")
if pb.Grid == nil {
- // fmt.Info("grid = nil")
+ // fmt.Println("grid = nil")
} else {
- // fmt.Info("grid.Id =", pb.Grid.Id)
+ // fmt.Println("grid.Id =", pb.Grid.Id)
}
if cursize, ok := getTerminalWidth(); ok {
TERMSIZE = cursize
@@ -32,7 +36,7 @@ func PrintTableLimit(pb *guipb.Table, limit int) {
var args []string
var sizes []int
- // fmt.Info("INFO: table len=", len(pb.AnyCols))
+ // fmt.Println("INFO: table len=", len(pb.AnyCols))
// first print the table header
for _, col := range pb.AnyCols {
args = append(args, col.Header.Name)
@@ -42,10 +46,13 @@ func PrintTableLimit(pb *guipb.Table, limit int) {
sizes = append(sizes, int(col.Attr.Width))
}
}
- // header, _ := StandardTableRowDebug(sizes, args)
- // fmt.Info(header)
- header, _ := StandardTableRow(sizes, args)
- fmt.Println(header)
+ if debug {
+ header, _ := StandardTableRowDebug(sizes, args)
+ fmt.Println(header)
+ } else {
+ header, _ := StandardTableRow(sizes, args)
+ fmt.Println(header)
+ }
var counter int
// now print the table rows
@@ -59,7 +66,13 @@ func PrintTableLimit(pb *guipb.Table, limit int) {
fmt.Println("cobol TABLE CELL FAILED", col.Header.Name, i, val, ok)
}
}
- line, fmtline := StandardTableRow(sizes, cells)
+ var line string
+ var fmtline string
+ if debug {
+ line, fmtline = StandardTableRowDebug(sizes, cells)
+ } else {
+ line, fmtline = StandardTableRow(sizes, cells)
+ }
if os.Getenv("TABLEPB_VERBOSE") == "true" {
line += "FMT: " + fmtline
}
diff --git a/time.string.go b/time.string.go
index bfa0007..96afe65 100644
--- a/time.string.go
+++ b/time.string.go
@@ -24,6 +24,9 @@ import (
// --------------------------------------------------------------------------------
func doTimeString(BUILDTIME string) (*time.Time, error) {
+ if strings.TrimSpace(BUILDTIME) == "" {
+ return nil, IsBlank
+ }
parts := strings.Split(BUILDTIME, " ")
if len(parts) == 1 {
return doTimeSingleString(parts[0])