summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-26 09:35:01 -0500
committerJeff Carr <[email protected]>2025-10-26 09:35:01 -0500
commit161347d22985c808c912c141ce8f55602f1dc731 (patch)
treeb213d9a1c61c589f2cba02e9785efc8f9daef4eb
parent5ff98fee1dd4731c97b54f039ddcf26d15d68193 (diff)
tighten the belts
-rw-r--r--structs.go33
-rw-r--r--theMagicOfAutocomplete.go2
-rw-r--r--verifyApplication.go32
3 files changed, 26 insertions, 41 deletions
diff --git a/structs.go b/structs.go
index 36842ba..6dbf312 100644
--- a/structs.go
+++ b/structs.go
@@ -8,21 +8,20 @@ var PB *Argv
// this is a work in progress
type AutoType struct {
- pb *Argv // the protobuf for the current process
- all *Argvs // the history of argv
- last *Argv // the pb from the last time the user tried autocomplete
- Err error // store any errors from argv
- debug bool // is dubugging on?
- setupAuto bool // do shell autocomplete setup
- isAuto bool // try to do autocomplete
- id int // should be unique
- Argv func([]string) // the function for shell autocomplete
- initArgvFunc func() (string, string, string) // this is required. gets APPNAME, BUILDTIME & VERSION
- initGuiFunc func() error // this is required for 'gui' args to work
- mustParseFunc func() error // calls go-arg.MustParse()
- examples func() string // some examples
- appExit func() // app Exit()
- buildtime func() (string, string) // some examples
- autoFunc func(*Argv) // also a function for autocomplete
- guiFunc func() error // enables Gui functions
+ pb *Argv // the protobuf for the current process
+ all *Argvs // the history of argv
+ last *Argv // the pb from the last time the user tried autocomplete
+ Err error // store any errors from argv
+ debug bool // is dubugging on?
+ setupAuto bool // do shell autocomplete setup
+ isAuto bool // try to do autocomplete
+ id int // should be unique
+ Argv func([]string) // the function for shell autocomplete
+ autoFunc func() error // also a function for autocomplete
+ initGuiFunc func() error // this is required for 'gui' args to work
+ mustParseFunc func() error // calls go-arg.MustParse()
+ examples func() string // some examples
+ appExit func() // app Exit()
+ buildtime func() (string, string) // some examples
+ guiFunc func() error // enables Gui functions
}
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index f67f9ff..db1a95b 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -116,7 +116,7 @@ func prepareStdout() {
me.pb.HelpCounter = 0
}
} else {
- me.autoFunc(me.pb) // run the autocomplete function the user made for their application
+ errors.Join(me.Err, me.autoFunc()) // run the autocomplete function the user made for their application
}
fmt.Fprintf(Stderr, "got to the end err(%v)\n", me.Err)
return
diff --git a/verifyApplication.go b/verifyApplication.go
index 18e61d7..b6f86a4 100644
--- a/verifyApplication.go
+++ b/verifyApplication.go
@@ -5,10 +5,10 @@ import "fmt"
// verify the application has the needed function calls defined
func verifyApplication(tmp interface{}) {
// START NEEDED FUNCS // 2025/10/18 (review in a few months)
- if tmp, ok := tmp.(initArgvI); ok {
- me.initArgvFunc = tmp.InitArgv
+ if tmp, ok := tmp.(autoFuncI); ok {
+ me.autoFunc = tmp.DoAutoComplete
} else {
- // panic("you must define in your app the function: (args) func InitArgv() (string, string, string)")
+ panic("you need to make the function argv.DoAutoComplete()")
}
if tmp, ok := tmp.(mustParseI); ok {
@@ -32,17 +32,6 @@ func verifyApplication(tmp interface{}) {
if tmp, ok := tmp.(examplesI); ok {
me.examples = tmp.Examples
}
- if tmp, ok := tmp.(autoFuncI); ok {
- me.autoFunc = tmp.DoAutoComplete
- } else {
- // panic("you need to make the function argv.DoAutoComplete()")
- }
-
- if tmp, ok := tmp.(sendCompletionStringsI); ok {
- me.autoFunc = tmp.SendCompletionStrings
- } else {
- // panic("you need to make the function argv.SendCompletionStrings()")
- }
if tmp, ok := tmp.(exitI); ok {
me.appExit = tmp.Exit
@@ -53,14 +42,16 @@ func verifyApplication(tmp interface{}) {
// WORKING ON START
-type initArgvI interface {
- InitArgv() (string, string, string)
-}
-
type mustParseI interface {
MustParse() error
}
+type autoFuncI interface {
+ // Version returns the version string that will be printed on a line by itself
+ // at the top of the help message.
+ DoAutoComplete() error
+}
+
type initGuiI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
@@ -77,11 +68,6 @@ type appnameI interface {
}
// deprecate
-type autoFuncI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- DoAutoComplete(*Argv)
-}
type sendCompletionStringsI interface {
// Version returns the version string that will be printed on a line by itself