From a2c9d4fed68598ebab7a174d51a44af43a7ff768 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 12 Oct 2025 06:27:25 -0500 Subject: finally merge these to sort it all out --- history.go | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 history.go (limited to 'history.go') diff --git a/history.go b/history.go deleted file mode 100644 index f26ba8e..0000000 --- a/history.go +++ /dev/null @@ -1,53 +0,0 @@ -package prep - -// essentially .bash_history, but in a protobuf and for any shell -// An elegant weapon... for a more civilized age. -// stores files ./cache/argv/.pb - -import ( - "time" - - "go.wit.com/lib/config" - durationpb "google.golang.org/protobuf/types/known/durationpb" -) - -func (newpb *Auto) getHistoryPB() (*Autos, error) { - all := NewAutos() - err := config.LoadCache(all, "argv", newpb.Argname) // loads ~/.cache/argv/forge.pb - if err != nil { - // newpb.History = false - return all, err - } - - if all.Len() == 0 { - // first time - all.Clone(newpb) - err = all.Save() - } - - var last *Auto - // find the last entry. this is dumb way to do it - for found := range all.IterAll() { - last = found - } - - // set the duration since the last auto complete - dur := time.Since(last.Ctime.AsTime()) - newpb.Duration = durationpb.New(dur) - - // roll the autocomplete file - if all.Len() > 15 { - newpb.Debugf("DEBUG: trim() history is over 100 len=%d vs new=%d", all.Len(), all.Len()-90) - all.Autos = all.Autos[all.Len()-10:] - // newall.Autos = all.Autos[0:10] - // for _, found := range all.Autos[0:10] { - // newall.Append(found) - // } - } - - all.Clone(newpb) - err = all.Save() - - newpb.Debugf("WRITE DEBUG: write PB='%s' len(pb)=%d config.Save().err=%v", all.Filename, all.Len(), err) - return all, err -} -- cgit v1.2.3