summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-12 06:17:32 -0500
committerJeff Carr <[email protected]>2025-10-12 06:17:32 -0500
commitcc600fe686e905a696cbc840decdd8d24b7bb72f (patch)
tree554d5f681be526406cb0ee826f85ce7257ada80b
parenta21a55ea6679b9e97ed1a51ac80e71c5d9770607 (diff)
more cleaning
-rw-r--r--history.go10
-rw-r--r--theMagicOfAutocomplete.go10
2 files changed, 11 insertions, 9 deletions
diff --git a/history.go b/history.go
index c048c1c..f26ba8e 100644
--- a/history.go
+++ b/history.go
@@ -11,12 +11,12 @@ import (
durationpb "google.golang.org/protobuf/types/known/durationpb"
)
-func (newpb *Auto) getHistoryPB() error {
+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 err
+ return all, err
}
if all.Len() == 0 {
@@ -25,10 +25,6 @@ func (newpb *Auto) getHistoryPB() error {
err = all.Save()
}
- if newpb.Debug {
- all.PrintHistory()
- }
-
var last *Auto
// find the last entry. this is dumb way to do it
for found := range all.IterAll() {
@@ -53,5 +49,5 @@ func (newpb *Auto) getHistoryPB() error {
err = all.Save()
newpb.Debugf("WRITE DEBUG: write PB='%s' len(pb)=%d config.Save().err=%v", all.Filename, all.Len(), err)
- return err
+ return all, err
}
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index d28dd8b..3202af3 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -31,7 +31,14 @@ func Autocomplete(dest any) *Auto {
pb.PrintDebug()
}
- pb.getHistoryPB() // read in the history protobuf file
+ all, err := pb.getHistoryPB() // read in the history protobuf file
+ if err != nil {
+ // there is no history
+ }
+
+ if pb.Debug {
+ all.PrintHistory()
+ }
// turn on debugging if duration < 200 milliseconds
dur := pb.Duration.AsDuration()
@@ -50,7 +57,6 @@ func Autocomplete(dest any) *Auto {
}
// pb.Debug = true
// pb.Debugf("DEBUG: MustParse(%v)", flags)
- var err error
myAuto.pp, err = arg.ParseFlags(flags, dest)
if err != nil {
pb.Debugf("DEBUG: Parse error: %v", err)