Compare commits

..

No commits in common. "16d7cb2696fdad119fb58cadd6f2220ba8c7aad5" and "87751f7c720b9af79bc5c5679b1f003ba5fae4ed" have entirely different histories.

2 changed files with 36 additions and 67 deletions

View File

@ -298,17 +298,15 @@ func Bash2(argname string, appAutoFunc func(*Auto)) *Auto {
} }
// also try to parse/send cur (?) // also try to parse/send cur (?)
// func Bash3(appAutoFunc func(*Auto), dest any) *Auto { func Bash3(argname string, appAutoFunc func(*Auto), dest any) *Auto {
func Bash3(dest any) *Auto {
myAuto = new(AutoArgs) myAuto = new(AutoArgs)
// myAuto.appName = argname myAuto.appName = argname
// myAuto.autoFunc = appAutoFunc myAuto.autoFunc = appAutoFunc
newTest(dest)
pb := parseArgv(myAuto.appName) pb := parseArgv(argname)
if pb.SetupAuto { if pb.SetupAuto {
// --bash was passed. try to configure bash-completion // --bash was passed. try to configure bash-completion
doBash2(myAuto.appName) doBash2(argname)
os.Exit(0) os.Exit(0)
} }
@ -317,6 +315,7 @@ func Bash3(dest any) *Auto {
pb.PrintDebug() 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 // turn on debugging if duration < 200 milliseconds
@ -347,8 +346,7 @@ func Bash3(dest any) *Auto {
pb.Debugf("DEBUG: myAuto.pp is ok after ParseFlags()") pb.Debugf("DEBUG: myAuto.pp is ok after ParseFlags()")
} }
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 { if pb.Debug {
// TODO: // TODO:
// check here to see if there was any completion text sent // check here to see if there was any completion text sent

View File

@ -40,32 +40,3 @@ func Debugger() {
CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output") CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output")
WARN = log.NewFlag("WARN", true, full, short, "should warn the user") 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
}
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 {
myAuto.appName = tmp.Appname()
} 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()")
}
}