1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
package argvpb
import "go.wit.com/log"
// this is a work in progress
// 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 mustParseI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
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.
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.
Appname() string
}
// 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
// at the top of the help message.
SendCompletionStrings(*Argv)
}
type buildtimeI interface {
Buildtime() (string, string)
}
type examplesI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
Examples() string
}
type guiI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
ArgvGui() error
}
type exitI interface {
// allows a custom app Exit()
Exit()
}
// 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.(mustParseI); ok {
me.mustParseFunc = tmp.MustParse
} else {
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 {
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")
}
if tmp, ok := tmp.(buildtimeI); ok {
me.buildtime = tmp.Buildtime
me.BUILDTIME, me.VERSION = me.buildtime()
} else {
// panic("your app is missing (argv) func Buildtime() (string, string)")
}
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.DoAutoComplete()")
}
if tmp, ok := tmp.(exitI); ok {
me.appExit = tmp.Exit
} else {
// 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")
}
|