diff options
Diffstat (limited to 'history.go')
| -rw-r--r-- | history.go | 53 |
1 files changed, 0 insertions, 53 deletions
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/<appname>.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 -} |
