diff options
| author | Jeff Carr <[email protected]> | 2025-09-18 16:48:16 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-18 16:48:16 -0500 |
| commit | 56297940f4c51f5ed48caefa06240baab2d51a60 (patch) | |
| tree | 2a18775781b7d20c7cdff23ef5bc9e1547065c79 /bash.new.go | |
| parent | 87751f7c720b9af79bc5c5679b1f003ba5fae4ed (diff) | |
this is how things are actually supposed to work
Diffstat (limited to 'bash.new.go')
| -rw-r--r-- | bash.new.go | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/bash.new.go b/bash.new.go index 708f02b..dddd16d 100644 --- a/bash.new.go +++ b/bash.new.go @@ -298,15 +298,16 @@ func Bash2(argname string, appAutoFunc func(*Auto)) *Auto { } // also try to parse/send cur (?) -func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto { +func Bash3(appAutoFunc func(*Auto), dest any) *Auto { myAuto = new(AutoArgs) - myAuto.appName = argname + // myAuto.appName = argname myAuto.autoFunc = appAutoFunc + newTest(dest) - pb := parseArgv(argname) + pb := parseArgv(myAuto.appName) if pb.SetupAuto { // --bash was passed. try to configure bash-completion - doBash2(argname) + doBash2(myAuto.appName) os.Exit(0) } @@ -315,37 +316,37 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto { pb.PrintDebug() } - if pb.IsAuto { - pb.doHandlePB() // read in the history protobuf file + pb.doHandlePB() // read in the history protobuf file - // turn on debugging if duration < 200 milliseconds - dur := pb.Duration.AsDuration() - if dur < time.Millisecond*200 { - pb.Debug = true - } + // turn on debugging if duration < 200 milliseconds + dur := pb.Duration.AsDuration() + if dur < time.Millisecond*200 { + pb.Debug = true + } - arg.Register(&argBash) - flags := []string{} - for _, s := range pb.Argv { - if s == "--autodebug" { - continue - } - flags = append(flags, s) - } - // pb.Debug = true - pb.Debugf("DEBUG: MustParse(%v)", flags) - var err error - myAuto.pp, err = arg.ParseFlags(flags, dest) - if err != nil { - pb.Debugf("DEBUG: Parse error: %v", err) + arg.Register(&argBash) + flags := []string{} + for _, s := range pb.Argv { + if s == "--autodebug" { + continue } + flags = append(flags, s) + } + // pb.Debug = true + pb.Debugf("DEBUG: MustParse(%v)", flags) + var err error + myAuto.pp, err = arg.ParseFlags(flags, dest) + if err != nil { + pb.Debugf("DEBUG: Parse error: %v", err) + } - if myAuto.pp == nil { - pb.Debugf("DEBUG: myAuto.pp == nil after ParseFlags()") - } else { - pb.Debugf("DEBUG: myAuto.pp is ok after ParseFlags()") - } + if myAuto.pp == nil { + pb.Debugf("DEBUG: myAuto.pp == nil after ParseFlags()") + } else { + pb.Debugf("DEBUG: myAuto.pp is ok after ParseFlags()") + } + if pb.IsAuto { appAutoFunc(pb) // run the autocomplete function the user made for their application if pb.Debug { // TODO: |
