summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index 8d78c62..b1bf044 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -26,13 +26,16 @@ func Autocomplete(dest any) *Auto {
}
pb := parseArgv(myAuto.appName) // parses os.Args into a protobuf
+ // try to register bash args for go-args
+ arg.Register(&argBash)
+ arg.Register(&argGui)
+
// not autocompleting. return go-arg & the application
if !pb.IsAuto {
// save the pb & history
all.Clone(pb)
errors.Join(err, all.Save())
- arg.Register(&argBash)
myAuto.pp = arg.MustParse(dest)
myAuto.err = err
return pb
@@ -84,9 +87,14 @@ func Autocomplete(dest any) *Auto {
if dur < time.Millisecond*200 {
pb.Debug = true
pb.Fast = true
+ pb.Fastcmd = pb.Cmd
+ if last.Fast {
+ if pb.Fastcmd == last.Fastcmd {
+ // do the smart something here
+ }
+ }
}
- arg.Register(&argBash)
flags := []string{}
for _, s := range pb.Argv {
if s == "--autodebug" {
@@ -94,10 +102,11 @@ func Autocomplete(dest any) *Auto {
}
flags = append(flags, s)
}
- // pb.Debug = true
- // pb.Debugf("DEBUG: MustParse(%v)", flags)
+
+ // use go-args to parse the structs so we can use them here
myAuto.pp, err = arg.ParseFlags(flags, dest)
if err != nil {
+ // users has command line arguments that won't parse with go-args
pb.Debugf("DEBUG: Parse error: %v", err)
}
@@ -110,6 +119,7 @@ func Autocomplete(dest any) *Auto {
// save now. this is near the end probably
all.Clone(pb)
errors.Join(err, all.Save())
+
// this is a work in progress
if pb.Last == "--gui" {
pb.Debugf("DEBUG: last=%s found --gui", pb.Last)