diff options
Diffstat (limited to 'theMagicOfAutocomplete.go')
| -rw-r--r-- | theMagicOfAutocomplete.go | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index 94fb38c..d9ef386 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -13,7 +13,6 @@ import ( "go.wit.com/lib/ENV" "go.wit.com/lib/cobol" "go.wit.com/lib/config" - "go.wit.com/log" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" ) @@ -56,9 +55,9 @@ func Autocomplete(dest any) *Argv { if me.guiFunc != nil { // register gui args me.guiFunc() - // log.Info("gui init") + // fmt.Println("gui init") } else { - // log.Info("no gui init") + // fmt.Println("no gui init") } // user is trying to setup bash or zsh autocomplete @@ -144,18 +143,38 @@ func Autocomplete(dest any) *Argv { if strings.HasPrefix(me.pb.Partial, "--argv") { me.pb.SendString("--argvdebug --argvhelp") - os.Exit(0) + me.pb.Stderr += fmt.Sprintln("argv override") + me.debug = true + me.pb.PrintStderrExit() + } + + // highjack "--gui" + if len(me.pb.Real) > 1 { + lastarg := me.pb.Real[len(me.pb.Real)-1] + // this is a work in progress + if lastarg == "--gui" { + me.pb.Debugf("DEBUG: real=(%v) found --gui", me.pb.Real) + me.pb.PrintStderr() + me.pb.SendString("andlabs gogui") + os.Exit(0) + } else { + // me.pb.Debugf("DEBUG: NO MATCH last='%s' found key '%s' = %s", me.last, key, val) + } } // use go-args to parse the structs so we can use them here // me.pp, err = arg.ParseFlags(flags, dest) if me.parseFlagsFunc == nil { - panic("argv.parseFlags() is nil") + me.pb.Stderr += fmt.Sprintln("argv.parseFlags() is nil") + me.debug = true + me.pb.PrintStderrExit() } if err := me.parseFlagsFunc(flags); err != nil { - log.Info("application parseFlags() err", err) - panic("argv.parseFlags() err. probably cmd doesn't really exist in struct") + 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.debug = true + me.pb.PrintStderrExit() } if len(flags) == 0 { @@ -171,19 +190,10 @@ func Autocomplete(dest any) *Argv { all.Clone(me.pb) errors.Join(err, all.Save()) - lastarg := me.pb.Real[len(me.pb.Real)-1] - // this is a work in progress - if lastarg == "--gui" { - me.pb.Debugf("DEBUG: real=(%v) found --gui", me.pb.Real) - me.pb.SendString("andlabs gogui") - os.Exit(0) - } else { - // me.pb.Debugf("DEBUG: NO MATCH last='%s' found key '%s' = %s", me.last, key, val) - } - if me.pb.Fast { if me.last.Fast { - os.Exit(0) + me.debug = true + me.pb.PrintStderr() } else { // this means the user is pressing tab. no longer doing stderr if me.pb.GetCmd() == "" { |
