summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tablePB.go19
-rw-r--r--termSize.go7
-rw-r--r--termSize_darwin.go4
-rw-r--r--termSize_linux.go6
-rw-r--r--termSize_windows.go4
-rw-r--r--time.string.go13
6 files changed, 31 insertions, 22 deletions
diff --git a/tablePB.go b/tablePB.go
index b462613..2cf42b0 100644
--- a/tablePB.go
+++ b/tablePB.go
@@ -7,19 +7,18 @@ import (
"os"
"go.wit.com/lib/protobuf/guipb"
- "go.wit.com/log"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func PrintTable(pb *guipb.Table) {
- // log.Info("print PB here")
+ // fmt.Info("print PB here")
if pb.Grid == nil {
- // log.Info("grid = nil")
+ // fmt.Info("grid = nil")
} else {
- // log.Info("grid.Id =", pb.Grid.Id)
+ // fmt.Info("grid.Id =", pb.Grid.Id)
}
if cursize, ok := getTerminalWidth(); ok {
TERMSIZE = cursize
@@ -28,7 +27,7 @@ func PrintTable(pb *guipb.Table) {
var args []string
var sizes []int
- // log.Info("INFO: table len=", len(pb.AnyCols))
+ // fmt.Info("INFO: table len=", len(pb.AnyCols))
// first print the table header
for _, col := range pb.AnyCols {
args = append(args, col.Header.Name)
@@ -39,9 +38,9 @@ func PrintTable(pb *guipb.Table) {
}
}
// header, _ := StandardTableRowDebug(sizes, args)
- // log.Info(header)
+ // fmt.Info(header)
header, _ := StandardTableRow(sizes, args)
- log.Info(header)
+ fmt.Println(header)
// now print the table rows
for i := range len(pb.AnyCols[0].Vals) {
@@ -50,14 +49,14 @@ func PrintTable(pb *guipb.Table) {
if val, ok := getAnyCell(col, i); ok {
cells = append(cells, val)
} else {
- log.Info("cobol TABLE CELL FAILED", col.Header.Name, i, val, ok)
+ fmt.Println("cobol TABLE CELL FAILED", col.Header.Name, i, val, ok)
}
}
line, fmtline := StandardTableRow(sizes, cells)
if os.Getenv("TABLEPB_VERBOSE") == "true" {
line += "FMT: " + fmtline
}
- log.Info(line)
+ fmt.Println(line)
}
}
@@ -110,7 +109,7 @@ func getAnyCell(col *guipb.AnyCol, row int) (string, bool) {
}
return "", false
default:
- log.Info("cell unhandled type", col.Attr.Type)
+ fmt.Println("cell unhandled type", col.Attr.Type)
}
// cellTime := r.Vals[row]
// s := FormatDuration(time.Since(cellTime.AsTime()))
diff --git a/termSize.go b/termSize.go
index 8595c5e..97a402a 100644
--- a/termSize.go
+++ b/termSize.go
@@ -1,10 +1,9 @@
package cobol
import (
+ "fmt"
"strings"
"unicode"
-
- "go.wit.com/log"
)
var WIDTH int = 120
@@ -22,7 +21,7 @@ func getTerminalWidth() (int, bool) {
// like the perl Chomp but with the terminal width
func TerminalChomp(cut string) string {
i, _ := getTerminalWidth()
- // log.Info("cobol.TerminalCut() at ", i)
+ // fmt.Info("cobol.TerminalCut() at ", i)
// TrimRightFunc removes all trailing runes r from the string s that satisfy f(r).
// unicode.IsSpace reports whether the rune is a space character.
@@ -31,6 +30,6 @@ func TerminalChomp(cut string) string {
if i >= len(cut) {
return cut
} else {
- return log.Sprintf("%s", cut[0:i])
+ return fmt.Sprintf("%s", cut[0:i])
}
}
diff --git a/termSize_darwin.go b/termSize_darwin.go
index 0702792..a70c1c8 100644
--- a/termSize_darwin.go
+++ b/termSize_darwin.go
@@ -1,9 +1,9 @@
package cobol
import (
+ "fmt"
"os"
- "go.wit.com/log"
"golang.org/x/term"
)
@@ -16,7 +16,7 @@ func osTerminalWidth() (int, bool) {
WIDTH, _, err = term.GetSize(int(os.Stdout.Fd()))
if err != nil {
// If we can't get the size for some reason, fall back to the default.
- log.Printf("could not get terminal size: %v", err)
+ fmt.Printf("could not get terminal size: %v", err)
return WIDTH, false
}
return WIDTH, true
diff --git a/termSize_linux.go b/termSize_linux.go
index 34201ac..392efa3 100644
--- a/termSize_linux.go
+++ b/termSize_linux.go
@@ -1,9 +1,9 @@
package cobol
import (
+ "fmt"
"os"
- "go.wit.com/log"
"golang.org/x/term"
)
@@ -21,7 +21,7 @@ func osTerminalWidth() (int, bool) {
WIDTH, _, err = term.GetSize(int(os.Stdout.Fd()))
if err != nil {
// If we can't get the size for some reason, fall back to the default.
- log.Printf("could not get terminal size: %v", err)
+ fmt.Printf("could not get terminal size: %v", err)
return WIDTH, false
}
return WIDTH, true
@@ -38,7 +38,7 @@ func ttyGetSize() (int, int, error) {
}
w, h, err := term.GetSize(int(tty.Fd()))
if err != nil {
- log.Info("linux.osTerminalWidth tty.Fd() err", w, h, err)
+ fmt.Println("linux.osTerminalWidth tty.Fd() err", w, h, err)
}
return w, h, err
}
diff --git a/termSize_windows.go b/termSize_windows.go
index 0702792..a70c1c8 100644
--- a/termSize_windows.go
+++ b/termSize_windows.go
@@ -1,9 +1,9 @@
package cobol
import (
+ "fmt"
"os"
- "go.wit.com/log"
"golang.org/x/term"
)
@@ -16,7 +16,7 @@ func osTerminalWidth() (int, bool) {
WIDTH, _, err = term.GetSize(int(os.Stdout.Fd()))
if err != nil {
// If we can't get the size for some reason, fall back to the default.
- log.Printf("could not get terminal size: %v", err)
+ fmt.Printf("could not get terminal size: %v", err)
return WIDTH, false
}
return WIDTH, true
diff --git a/time.string.go b/time.string.go
index 595fb4f..b3aa166 100644
--- a/time.string.go
+++ b/time.string.go
@@ -8,7 +8,7 @@ import (
)
func doTimeString(BUILDTIME string) (*time.Time, error) {
- parts := strings.Split(BUILDTIME, ".")
+ parts := strings.Split(BUILDTIME, " ")
if len(parts) == 1 {
// The input epoch seconds
// epochSeconds := int64(1758646486)
@@ -22,5 +22,16 @@ func doTimeString(BUILDTIME string) (*time.Time, error) {
t := time.Unix(epochSeconds, 0)
return &t, errors.New("treated string as seconds")
}
+ if len(parts) >= 2 {
+ if len(parts[0]) == 10 && len(parts[1]) == 8 {
+ // log.Info("GOT HERE also", BUILDTIME)
+ const layout = "2006/01/02 15:04:05"
+ t, err := time.ParseInLocation(layout, parts[0]+" "+parts[1], time.UTC)
+ if err == nil {
+ return &t, nil
+ }
+
+ }
+ }
return nil, NewFeature
}