summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-25 09:26:18 -0500
committerJeff Carr <[email protected]>2025-10-25 09:26:18 -0500
commit22fcb080548bc57847c2405d724e9f40364fa621 (patch)
tree114dc2941073ba90b5e1a7379fe9d5b280709f5a /theMagicOfAutocomplete.go
parent221839190ba296268926589dd50416c3e7cac24a (diff)
still not working
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index a2ff7a9..85b89b0 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -64,7 +64,6 @@ func Autocomplete(dest any) *Argv {
// --bash or --zsh was passed. try to configure bash-completion
MakeAutocompleteFiles(me.pb.AppInfo.APPNAME)
// never forget to exit here or you will hate yourself and the choices you have made
- savePB()
saveAndExit()
}
@@ -106,17 +105,16 @@ func doAutocomplete() {
}
if me.debug {
- // dump debug info
+ // add an initial debug line
me.pb.PrintDebug(me.last.GetCmd())
- // me.all.PrintHistory()
- // me.pb.PrintStderr()
}
if strings.HasPrefix(me.pb.Partial, "--argv") {
me.pb.SendString("--argvdebug --argvhelp")
me.pb.Stderr += fmt.Sprintln("argv override")
me.debug = true
- me.pb.PrintStderrExit()
+ me.pb.PrintStderr()
+ saveAndExit()
}
// highjack "--gui"
@@ -127,7 +125,6 @@ func doAutocomplete() {
me.pb.Debugf("DEBUG: real=(%v) found --gui", me.pb.Real)
me.pb.PrintStderr()
me.pb.SendString("andlabs gogui")
- savePB()
saveAndExit()
} else {
// me.pb.Debugf("DEBUG: NO MATCH last='%s' found key '%s' = %s", last, key, val)
@@ -135,26 +132,31 @@ func doAutocomplete() {
}
// use go-args to parse the structs so we can use them here
- // me.pp, err = arg.ParseFlags(flags, dest)
+ // me.pp, err = arg.ParseFlags(pb.Real, dest)
if me.parseFlagsFunc == nil {
me.pb.Stderr += fmt.Sprintln("argv.parseFlags() is nil")
me.debug = true
- me.pb.PrintStderrExit()
+ me.pb.PrintStderr()
+ me.pb.PrintStdout()
+ saveAndExit()
}
- if err := me.parseFlagsFunc(me.flags); err != nil {
+ if err := me.parseFlagsFunc(me.pb.Real); err != nil {
me.pb.Stderr += fmt.Sprintf("application parseFlags() err(%v)\n", err)
me.pb.Stderr += fmt.Sprintln("argv.parseFlags() err. probably cmd doesn't really exist in struct")
+ me.all.PrintHistory(me.last.GetCmd())
me.debug = true
- me.pb.PrintStderrExit()
+ me.pb.PrintStderr()
+ me.pb.PrintStdout()
+ saveAndExit()
}
- if len(me.flags) == 0 {
+ if len(me.pb.Real) == 0 {
// error is normal if there are no command line args
} else {
if me.Err != nil {
// users has command line arguments that won't parse with go-args
- me.pb.Debugf("DEBUG: Parse error: %v flags%v", me.Err, me.flags)
+ me.pb.Debugf("DEBUG: Parse error: %v real(%v)", me.Err, me.pb.Real)
}
}
@@ -166,7 +168,6 @@ func doAutocomplete() {
if me.pb.HelpCounter < 3 {
me.pb.PrintStderr()
} else {
- savePB()
saveAndExit()
}
} else {
@@ -192,7 +193,6 @@ func doAutocomplete() {
// if not, send "reset bash newline\n" to cause bash to redraw PS1 for the user
}
}
- savePB()
saveAndExit()
}
@@ -206,6 +206,7 @@ func savePB() {
}
func saveAndExit() {
+ savePB()
os.Exit(0)
}