summaryrefslogtreecommitdiff
path: root/interface.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-18 08:00:52 -0500
committerJeff Carr <[email protected]>2025-10-18 08:00:52 -0500
commitf683e1adc9fd612a67f6cc34ba3188a8120f87d7 (patch)
tree925f08631f9ecb192adb8fdc2863612b68c3f1a6 /interface.go
parentb2c353f48082a1d581bee0b6ee71c93f58bff603 (diff)
still tinkering
Diffstat (limited to 'interface.go')
-rw-r--r--interface.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/interface.go b/interface.go
index 13b2e71..a303515 100644
--- a/interface.go
+++ b/interface.go
@@ -5,24 +5,23 @@ 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 writeHelpForAutocompleteI interface {
+ WriteHelpForAutocomplete(string, ...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.
@@ -87,6 +86,12 @@ func findAppInfo(tmp interface{}) {
panic("you must define in your app the function: func (args) MustParse() error")
}
+ if tmp, ok := tmp.(writeHelpForAutocompleteI); ok {
+ me.writeHelpForAutocompleteFunc = tmp.WriteHelpForAutocomplete
+ } else {
+ helpWriteHelpForAutocomplete()
+ }
+
if tmp, ok := tmp.(parseFlagsI); ok {
me.parseFlagsFunc = tmp.ParseFlags
} else {
@@ -139,6 +144,21 @@ func findAppInfo(tmp interface{}) {
}
}
+// func (p *Parser) WriteHelpForAutocomplete(stderr io.Writer, stdout io.Writer, partial string, subcommand ...string) error {
+// me.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, partial, cmd...)
+func helpWriteHelpForAutocomplete() {
+ log.Info("")
+ log.Info("// this will print the help for the subcmd")
+ log.Info("func (args) WriteHelpForAutocomplete(part string, subcmd ...string) error {")
+ log.Info(" return argvpp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, part, subcmd...)")
+ log.Info("}")
+ log.Info("")
+ log.Info("Just copy the argv.template.go file from forge")
+ log.Info("")
+
+ panic("you must define this function in your application code")
+}
+
func parseFlagsHelp() {
log.Info("")
log.Info("// this function will send the current argv PB to go-args for parsing")