summaryrefslogtreecommitdiff
path: root/interface.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-18 06:37:00 -0500
committerJeff Carr <[email protected]>2025-10-18 06:37:00 -0500
commitb2c353f48082a1d581bee0b6ee71c93f58bff603 (patch)
tree1a77d472dda8d720b13e15f4ca39d8645396d5f3 /interface.go
parent8d1a704d6f41b5f08aabc276d1476266f51c5b63 (diff)
pass the flags to the go-arg parser
Diffstat (limited to 'interface.go')
-rw-r--r--interface.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/interface.go b/interface.go
index 72c1b50..13b2e71 100644
--- a/interface.go
+++ b/interface.go
@@ -17,6 +17,12 @@ type mustParseI interface {
MustParse() error
}
+type parseFlagsI interface {
+ // Version returns the version string that will be printed on a line by itself
+ // at the top of the help message.
+ ParseFlags([]string) 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.
@@ -81,6 +87,12 @@ func findAppInfo(tmp interface{}) {
panic("you must define in your app the function: func (args) MustParse() error")
}
+ if tmp, ok := tmp.(parseFlagsI); ok {
+ me.parseFlagsFunc = tmp.ParseFlags
+ } else {
+ parseFlagsHelp()
+ }
+
if tmp, ok := tmp.(initGuiI); ok {
me.initGuiFunc = tmp.InitGui
if err := tmp.InitGui(); err != nil {
@@ -126,3 +138,14 @@ func findAppInfo(tmp interface{}) {
// panic("you need to make the function argv.Exit()")
}
}
+
+func parseFlagsHelp() {
+ log.Info("")
+ log.Info("// this function will send the current argv PB to go-args for parsing")
+ log.Info("func (args) ParseFlags(flags []string) error {")
+ log.Info(" arg.ParseFlags(flags)")
+ log.Info("}")
+ log.Info("")
+
+ panic("you must define in your app the function: func (args) ParseFlags([]string) error")
+}