diff options
| author | Jeff Carr <[email protected]> | 2025-10-12 01:58:49 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-12 01:58:49 -0500 |
| commit | bf9f85a721d6045e631df9abe91f02d9723fcd19 (patch) | |
| tree | 453d0b67ed5cb126482967291ce33e61e9e277e1 /theMagicOfAutocomplete.go | |
| parent | c6d9986d986b5d5b170335ff3a8f3e06d4c003ea (diff) | |
fantastic
Diffstat (limited to 'theMagicOfAutocomplete.go')
| -rw-r--r-- | theMagicOfAutocomplete.go | 39 |
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() |
