geez. this makes things easier

This commit is contained in:
Jeff Carr 2025-09-18 16:53:44 -05:00
parent 56297940f4
commit 16d7cb2696
2 changed files with 16 additions and 3 deletions

View File

@ -298,10 +298,11 @@ func Bash2(argname string, appAutoFunc func(*Auto)) *Auto {
}
// also try to parse/send cur (?)
func Bash3(appAutoFunc func(*Auto), dest any) *Auto {
// func Bash3(appAutoFunc func(*Auto), dest any) *Auto {
func Bash3(dest any) *Auto {
myAuto = new(AutoArgs)
// myAuto.appName = argname
myAuto.autoFunc = appAutoFunc
// myAuto.autoFunc = appAutoFunc
newTest(dest)
pb := parseArgv(myAuto.appName)
@ -347,7 +348,7 @@ func Bash3(appAutoFunc func(*Auto), dest any) *Auto {
}
if pb.IsAuto {
appAutoFunc(pb) // run the autocomplete function the user made for their application
myAuto.autoFunc(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

View File

@ -49,6 +49,12 @@ type Appnamed interface {
Appname() string
}
type AutoFuncd interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
DoAutoComplete(*Auto)
}
// Described is the interface that the destination struct should implement to
func newTest(tmp interface{}) {
if tmp, ok := tmp.(Appnamed); ok {
@ -56,4 +62,10 @@ func newTest(tmp interface{}) {
} else {
panic("you need to make the function argv.Appname()")
}
if tmp, ok := tmp.(AutoFuncd); ok {
myAuto.autoFunc = tmp.DoAutoComplete
} else {
panic("you need to make the function argv.DoAutoComplete()")
}
}