summaryrefslogtreecommitdiff
path: root/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'interface.go')
-rw-r--r--interface.go47
1 files changed, 37 insertions, 10 deletions
diff --git a/interface.go b/interface.go
index 02541a6..d1d3aec 100644
--- a/interface.go
+++ b/interface.go
@@ -1,9 +1,25 @@
package argvpb
+import "go.wit.com/log"
+
// this is a work in progress
-// Versioned is the interface that the destination struct should implement to
-// make a version string appear at the top of the help message.
+// WORKING ON START
+type initArgvI interface {
+ // Version returns the version string that will be printed on a line by itself
+ // at the top of the help message.
+ InitArgv() (string, string, string)
+}
+
+type initGuiI interface {
+ // Version returns the version string that will be printed on a line by itself
+ // at the top of the help message.
+ InitGui() error
+}
+
+// WORKING ON END
+
+// NOTSURE ABOUT START
type appnameI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
@@ -46,10 +62,28 @@ type exitI interface {
// Described is the interface that the destination struct should implement to
func findAppInfo(tmp interface{}) {
+ // THIS STUFF IS FINALIZED FOR NOW 2025/10/18 (review in a few months)
+ if tmp, ok := tmp.(initArgvI); ok {
+ me.ARGNAME, me.BUILDTIME, me.VERSION = tmp.InitArgv()
+ } else {
+ panic("you must define in your app the function: (args) func InitArgv() (string, string, string)")
+ }
+
+ if tmp, ok := tmp.(initGuiI); ok {
+ me.initGuiFunc = tmp.InitGui
+ if err := tmp.InitGui(); err != nil {
+ log.Info("go.wit.com/gui failed to initialize", err)
+ panic("gui failed to init")
+ }
+ } else {
+ panic("you must add this function to argv.go: (argv) func InitGui() error")
+ }
+
+ // TODO: SORT OUT STUFF BELOW HERE
if tmp, ok := tmp.(appnameI); ok {
me.ARGNAME = tmp.Appname()
} else {
- panic("you must define in your app the function: (argv) func Appname() string")
+ // panic("you must define in your app the function: (argv) func Appname() string")
}
if tmp, ok := tmp.(buildtimeI); ok {
@@ -62,13 +96,6 @@ func findAppInfo(tmp interface{}) {
if tmp, ok := tmp.(examplesI); ok {
me.examples = tmp.Examples
}
-
- if tmp, ok := tmp.(guiI); ok {
- me.guiFunc = tmp.ArgvGui
- } else {
- // panic("you must add this function to argv.go: (argv) func ArgvGui() error")
- }
-
if tmp, ok := tmp.(autoFuncI); ok {
me.autoFunc = tmp.DoAutoComplete
} else {