summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-28 20:26:35 -0500
committerJeff Carr <[email protected]>2025-10-28 20:26:35 -0500
commitd01a280e32cca2809c35d02cef25cc6c691a0e1e (patch)
treeb02cc25e2ea8fb5d0383f2cf7a3ca24b65a62e71
parent69a8ae0bdc33e898bee5046bfee73692879f5297 (diff)
more dbg output cleanups
-rw-r--r--argv.Print.go12
-rw-r--r--argv.proto29
-rw-r--r--init.go12
-rw-r--r--theMagicOfAutocomplete.go5
4 files changed, 29 insertions, 29 deletions
diff --git a/argv.Print.go b/argv.Print.go
index f57cbd5..68c2391 100644
--- a/argv.Print.go
+++ b/argv.Print.go
@@ -29,12 +29,12 @@ func (pb *Argv) PrintDebug(last string) {
}
func (pb *Argv) PrintDebugNew(msg string, last *Argv) {
- cmd := fmt.Sprintf("cmd='%s'", pb.GetCmd())
// var arglast string
// arglast = fmt.Sprintf("last='%s'", last.GetCmd())
partial := fmt.Sprintf("p='%s'", pb.Partial)
age := cobol.Duration(pb.Ctime)
- dur := cobol.Duration(pb.Duration)
+ pdur := cobol.Duration(pb.Duration)
+ argvdur := cobol.Duration(pb.ArgvDuration)
var dbg string
if me.debug {
@@ -42,10 +42,10 @@ func (pb *Argv) PrintDebugNew(msg string, last *Argv) {
} else {
dbg = "dbg=0"
}
- sargv := fmt.Sprintf("argv(%v)", pb.Real)
- fast := fmt.Sprintf("F%-2dout%-2derr%-2d", pb.Fast, pb.OutCounter, pb.ErrCounter)
- top := fmt.Sprintf("%-4.4s age=(%s)dur(%s) %s %s %-12.12s", pb.Uuid, age, dur, dbg, fast, cmd)
- Debugf("%s: %s %-12.12s %s cmd=%s real='%v' len(%d)", msg, top, partial, pb.GetCmd(), sargv, pb.Real, me.all.Len())
+ 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) {
diff --git a/argv.proto b/argv.proto
index 16f01a9..b2c5ede 100644
--- a/argv.proto
+++ b/argv.proto
@@ -27,20 +27,21 @@ message ArgTree {
}
message Argv { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:nomutex`
- google.protobuf.Timestamp ctime = 1; // when the user tried this autocomplete
- google.protobuf.Duration duration = 2; // time since the last autocomplete
- App appInfo = 3;
- repeated string args = 4; // a copy of os.Args
- repeated string real = 5; // what will really be sent to the application
- string subcmd = 6; // the subcommand being processed. For "git pull <tab>", cmd would be "pull"
- string partial = 7; // if the user has only partially inputed something
- int32 fast = 8; // is autocomplete running quickly?
- string stdout = 9; // all output is loaded here before being sent to the shell
- string stderr = 10; // all output is loaded here before being sent to the shell
- string stddbg = 11; // all output is loaded here before being sent to the shell
- int32 outCounter = 12; // counter to track if the help text has been sent to Stderr
- int32 errCounter = 13; // counter to track if the help text has been sent to Stderr
- string uuid = 14; // all output is loaded here before being sent to the shell
+ google.protobuf.Timestamp ctime = 1; // set at the start of argv.Init()
+ google.protobuf.Duration duration = 2; // could mean lots of things
+ google.protobuf.Duration argvDuration = 3; // how long autocomplete & match took
+ App appInfo = 4;
+ repeated string args = 5; // a copy of os.Args
+ repeated string real = 6; // what will really be sent to the application
+ string subcmd = 7; // the subcommand being processed. For "git pull <tab>", cmd would be "pull"
+ string partial = 8; // if the user has only partially inputed something
+ int32 fast = 9; // is autocomplete running quickly?
+ string stdout = 10; // all output is loaded here before being sent to the shell
+ string stderr = 11; // all output is loaded here before being sent to the shell
+ string stddbg = 12; // all output is loaded here before being sent to the shell
+ int32 outCounter = 13; // counter to track if the help text has been sent to Stderr
+ int32 errCounter = 14; // counter to track if the help text has been sent to Stderr
+ string uuid = 15; // all output is loaded here before being sent to the shell
}
message Argvs { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:nomutex`
diff --git a/init.go b/init.go
index 1c056d1..7c9e9f8 100644
--- a/init.go
+++ b/init.go
@@ -15,6 +15,11 @@ func Init(dest any, APPNAME string, anyString string, VERSION string) {
PB = me.pb
me.debug = true
+ // set the start time of the binary
+ now := time.Now()
+ PB.Ctime = timestamppb.New(now)
+ me.pb.Uuid = uuid.New().String() // todo: add options to track this
+
// needed by bash for autocomplete, help & debugging
Stdout = NewStringWriter(&PB.Stdout) // bash uses this to match strings
Stderr = NewStringWriter(&PB.Stderr) // bash dumps this as "help" about application options
@@ -43,13 +48,6 @@ func Init(dest any, APPNAME string, anyString string, VERSION string) {
}
me.pb.AppInfo = app
- // shouldn't be needed but is because this code doesn't work right yet
- me.pb.Uuid = uuid.New().String()
-
- // set the start time of the binary
- now := time.Now()
- me.pb.Ctime = timestamppb.New(now)
-
// makes sure the application has the
// needed functions defined, otherwise dies
verifyApplication(dest)
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index 79154e9..95585bd 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -116,6 +116,8 @@ func prepareStdout() {
func savePB() {
// save now. this is near the end probably
+ dur := time.Since(PB.Ctime.AsTime())
+ me.pb.ArgvDuration = durationpb.New(dur) // track how long autocomplete took
me.all.Append(me.pb)
// npb := new(Argv)
// npb.Uuid = uuid.New().String()
@@ -155,7 +157,6 @@ func saveAndExit() {
}
// sets me.last
-// computes me.pb.Duration
func examineArgvHistory() {
me.all = NewArgvs()
// loads the argv autocomplete history file
@@ -243,7 +244,7 @@ func examineArgvHistory() {
me.pb.Fast = 0
}
// user keeps hitting tab. trigger help
- if me.pb.Duration.AsDuration() < time.Millisecond*300 {
+ if dur < time.Millisecond*300 {
me.pb.Fast = me.last.Fast + 1
} else {
me.pb.Fast = 0