summaryrefslogtreecommitdiff
path: root/bash.new.go
diff options
context:
space:
mode:
Diffstat (limited to 'bash.new.go')
-rw-r--r--bash.new.go40
1 files changed, 25 insertions, 15 deletions
diff --git a/bash.new.go b/bash.new.go
index d6ac13b..708f02b 100644
--- a/bash.new.go
+++ b/bash.new.go
@@ -253,21 +253,17 @@ func parseArgv(argname string) *Auto {
newauto.Cmd = s
break
}
- if newauto.Cmd == "" {
- newauto.Cmd = strings.Join(newauto.Argv, "BLAH")
+ if newauto.Partial == "'"+newauto.Cmd+"'" {
+ // not really a command, it's just a partially inputed string from the user
+ newauto.Cmd = ""
}
- return newauto
+ // if newauto.Cmd == "" {
+ // newauto.Cmd = strings.Join(newauto.Argv, "BLAH")
+ // }
}
return newauto
}
-// MustParse processes command line arguments and exits upon failure
-func MustParse(dest ...interface{}) *arg.Parser {
- // arg.
- // register = append(register, dest...)
- return arg.MustParse(dest)
-}
-
// also try to parse/send cur (?)
func Bash2(argname string, appAutoFunc func(*Auto)) *Auto {
pb := parseArgv(argname)
@@ -320,12 +316,14 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
}
if pb.IsAuto {
- pb.doHandlePB()
- if pb.Debug {
- // TODO:
- // check here to see if there was any completion text sent
- // if not, send "reset bash newline\n" to cause bash to redraw PS1 for the user
+ 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
}
+
arg.Register(&argBash)
flags := []string{}
for _, s := range pb.Argv {
@@ -334,6 +332,7 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
}
flags = append(flags, s)
}
+ // pb.Debug = true
pb.Debugf("DEBUG: MustParse(%v)", flags)
var err error
myAuto.pp, err = arg.ParseFlags(flags, dest)
@@ -341,7 +340,18 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
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()")
+ }
+
appAutoFunc(pb) // run the autocomplete function the user made for their application
+ if pb.Debug {
+ // TODO:
+ // check here to see if there was any completion text sent
+ // if not, send "reset bash newline\n" to cause bash to redraw PS1 for the user
+ }
os.Exit(0)
}