summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go39
1 files changed, 14 insertions, 25 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index 9397373..9de2d7f 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -14,30 +14,17 @@ import (
"go.wit.com/log"
)
-// deprecate
-func Bash3(dest any) *Auto {
- return Autocomplete(dest)
-}
-
-// deprecate
-func Bash(dest any) *Auto {
- return Autocomplete(dest)
-}
-
func Autocomplete(dest any) *Auto {
myAuto = new(AutoArgs)
findAppInfo(dest) // parses back to main() for argv info
- pb := parseArgv(myAuto.appName)
+ pb := parseArgv(myAuto.appName) // parses os.Args into a protobuf
if pb.SetupAuto {
// --bash was passed. try to configure bash-completion
- doBash(myAuto.appName)
+ makeAutocompleteFiles(myAuto.appName)
os.Exit(0)
}
- myAuto.match = make(map[string]string)
- myAuto.match["--gui"] = "andlabs gocui"
-
if pb.Debug {
// dump debug info
pb.PrintDebug()
@@ -76,15 +63,17 @@ func Autocomplete(dest any) *Auto {
}
if pb.IsAuto {
- for key, val := range myAuto.match {
- if pb.Last == key {
- pb.Debugf("DEBUG: last=%s found key %s = %s", pb.Last, key, val)
- pb.Autocomplete2(val)
- os.Exit(0)
- } else {
- // pb.Debugf("DEBUG: NO MATCH last='%s' found key '%s' = %s", pb.Last, key, val)
- }
+ // myAuto.match = make(map[string]string)
+ // myAuto.match["--gui"] = "andlabs gocui"
+ // for key, val := range myAuto.match {
+ if pb.Last == "--gui" {
+ pb.Debugf("DEBUG: last=%s found --gui", pb.Last)
+ pb.Autocomplete2("andlabs gogui")
+ os.Exit(0)
+ } else {
+ // pb.Debugf("DEBUG: NO MATCH last='%s' found key '%s' = %s", pb.Last, key, val)
}
+ // }
if myAuto.autoFunc == nil {
pb.SubCommand(pb.Argv...)
} else {
@@ -103,8 +92,8 @@ func Autocomplete(dest any) *Auto {
return pb
}
-// makes a bash autocomplete file for your command
-func doBash(argname string) {
+// makes a autocomplete file for your command
+func makeAutocompleteFiles(argname string) {
fmt.Println(makeBashCompletionText2(argname))
homeDir, err := os.UserHomeDir()