this is how things are actually supposed to work
This commit is contained in:
parent
87751f7c72
commit
56297940f4
11
bash.new.go
11
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,7 +316,6 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
|
|||
pb.PrintDebug()
|
||||
}
|
||||
|
||||
if pb.IsAuto {
|
||||
pb.doHandlePB() // read in the history protobuf file
|
||||
|
||||
// turn on debugging if duration < 200 milliseconds
|
||||
|
@ -346,6 +346,7 @@ func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
|
|||
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:
|
||||
|
|
17
debugger.go
17
debugger.go
|
@ -40,3 +40,20 @@ func Debugger() {
|
|||
CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output")
|
||||
WARN = log.NewFlag("WARN", true, full, short, "should warn the user")
|
||||
}
|
||||
|
||||
// Versioned is the interface that the destination struct should implement to
|
||||
// make a version string appear at the top of the help message.
|
||||
type Appnamed interface {
|
||||
// Version returns the version string that will be printed on a line by itself
|
||||
// at the top of the help message.
|
||||
Appname() string
|
||||
}
|
||||
|
||||
// Described is the interface that the destination struct should implement to
|
||||
func newTest(tmp interface{}) {
|
||||
if tmp, ok := tmp.(Appnamed); ok {
|
||||
myAuto.appName = tmp.Appname()
|
||||
} else {
|
||||
panic("you need to make the function argv.Appname()")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue