From bca3f42ae8ddf7e56c93a143b915a8dc9f3326f4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 28 Oct 2025 23:42:23 -0500 Subject: rename now that things are getting cleaner --- argv.Print.go | 134 ---------------------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 argv.Print.go (limited to 'argv.Print.go') diff --git a/argv.Print.go b/argv.Print.go deleted file mode 100644 index 49b1089..0000000 --- a/argv.Print.go +++ /dev/null @@ -1,134 +0,0 @@ -package argvpb - -// debug argv protobuf functions -// enable with --autodebug or Setenv( "AUTOCOMPLETE_VERBOSE" ) - -import ( - "fmt" - "os" - "strings" - - "go.wit.com/lib/cobol" - "go.wit.com/lib/config" -) - -func (pb *Argv) debugf(fmts string, parts ...any) { - debugf(fmts, parts...) -} - -// decides here to print to STDERR or not -func debugf(fmts string, parts ...any) { - fmts = strings.TrimSpace(fmts) - fmts += "\n" - // me.pb.Stderr += fmt.Sprintf(fmts, parts...) - fmt.Fprintf(Stddbg, fmts, parts...) -} - -// print out auto complete debugging info -func (pb *Argv) printDebug(last string) { - pb.printDebugNew("ARGV", me.last) -} - -func (pb *Argv) printDebugNew(msg string, last *Argv) { - // var arglast string - // arglast = fmt.Sprintf("last='%s'", last.GetCmd()) - partial := fmt.Sprintf("p='%s'", pb.Partial) - age := cobol.Duration(pb.Ctime) - pdur := cobol.Duration(pb.Duration) - argvdur := cobol.Duration(pb.ArgvDuration) - - var dbg string - if me.debug { - dbg = "dbg=1" - } else { - dbg = "dbg=0" - } - lens := fmt.Sprintf("len=%-2d,%-2d,%-2d", me.all.Len(), len(strings.Fields(pb.Stdout)), len(strings.Split(pb.Stderr, "\n"))) - fast := fmt.Sprintf("F%-2dout%-2derr%-2d %s", pb.Fast, pb.OutCounter, pb.ErrCounter, lens) - top := fmt.Sprintf("%-4.4s age=(%s)(%s)dur(%s) %s %s cmd=%-12.12s", pb.Uuid, age, pdur, argvdur, dbg, fast, pb.GetCmd()) - debugf("%s: %s %-12.12s real='%v'", msg, top, partial, pb.Real) -} - -func (all *Argvs) printHistory(msg string) { - counter := 0 - var last *Argv - // for pb := range all.Argv[0:10] { - for pb := range all.IterAll() { - counter += 1 - pb.printDebugNew(msg, last) - last = pb - if counter > 30 { - // sometimes I'm dumb - break - } - } -} - -func printStddbg() { - if !me.debug { - return - } - if config.Exists("/tmp/argv.debug") { - printStddbgFile() - return - } - lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") - if len(lines) == 0 { - return - } - fmt.Fprintf(os.Stderr, "\n") - for _, line := range lines { - fmt.Fprintf(os.Stderr, "%s\n", line) - } - fmt.Fprintf(os.Stderr, "\n") -} - -func printStddbgFile() { - if !me.debug { - return - } - f, err := os.OpenFile("/tmp/argv.debug", os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644) - if err != nil { - return - } - defer f.Close() - lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") - if len(lines) == 0 { - return - } - fmt.Fprintf(f, "\n") - for _, line := range lines { - fmt.Fprintf(f, "%s\n", line) - } - fmt.Fprintf(f, "\n") -} - -func printStderr() { - var lines []string - for _, line := range strings.Split(strings.TrimSpace(PB.Stderr), "\n") { - if strings.TrimSpace(line) == "" { - continue - } - lines = append(lines, line) - } - if len(lines) == 0 { - return - } - fmt.Fprintf(os.Stderr, "\n") - for _, line := range lines { - // line = strings.TrimSpace(line) - // if line == "" { - // continue - // } - fmt.Fprintf(os.Stderr, "%s\n", line) - } - fmt.Fprintf(os.Stderr, "\n") -} - -func printStdout() { - line := strings.TrimSpace(PB.Stdout) - if line == "" { - return - } - fmt.Fprintf(os.Stdout, " %s\n", line) -} -- cgit v1.2.3