summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface.go44
-rw-r--r--structs.go2
-rw-r--r--theMagicOfAutocomplete.go2
3 files changed, 46 insertions, 2 deletions
diff --git a/interface.go b/interface.go
index a303515..a21a0b4 100644
--- a/interface.go
+++ b/interface.go
@@ -22,6 +22,14 @@ type writeHelpForAutocompleteI interface {
WriteHelpForAutocomplete(string, ...string) error
}
+type writeHelpForAutocompleteDebugI interface {
+ WriteHelpForAutocompleteDebug(string, ...string) error
+}
+
+type writeHelpI interface {
+ WriteHelp() 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.
@@ -92,6 +100,18 @@ func findAppInfo(tmp interface{}) {
helpWriteHelpForAutocomplete()
}
+ if tmp, ok := tmp.(writeHelpForAutocompleteDebugI); ok {
+ me.writeHelpForAutocompleteDebugFunc = tmp.WriteHelpForAutocompleteDebug
+ } else {
+ helpWriteHelpForAutocompleteDebug()
+ }
+
+ if tmp, ok := tmp.(writeHelpI); ok {
+ me.writeHelpFunc = tmp.WriteHelp
+ } else {
+ helpWriteHelp()
+ }
+
if tmp, ok := tmp.(parseFlagsI); ok {
me.parseFlagsFunc = tmp.ParseFlags
} else {
@@ -144,6 +164,30 @@ func findAppInfo(tmp interface{}) {
}
}
+func helpWriteHelp() {
+ log.Info("")
+ log.Info("// add this funcgion: this will print the help")
+ log.Info("func (args) WriteHelp() error {")
+ log.Info(" me.pp.WriteHelp(os.Stderr)")
+ log.Info(" return nil")
+ log.Info("}")
+ log.Info("")
+
+ panic("best to just copy the argv.template.go file from forge")
+}
+
+func helpWriteHelpForAutocompleteDebug() {
+ log.Info("")
+ log.Info("// this will print the help for the subcmd")
+ log.Info("func (args) WriteHelpForAutocompleteDebug(part string, subcmd ...string) error {")
+ log.Info(" return argvpp.WriteHelpForAutocomplete(f, os.Stdout, part, subcmd...)")
+ log.Info("}")
+ log.Info("")
+ log.Info("cp ~/go/src/go.wit.com/apps/forge/argv.template.go .")
+
+ panic("best to just copy the argv.template.go file from forge")
+}
+
// 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() {
diff --git a/structs.go b/structs.go
index 491c774..1cf5b91 100644
--- a/structs.go
+++ b/structs.go
@@ -14,7 +14,7 @@ type AutoArgs struct {
parseFlagsFunc func([]string) error // calls go-arg.ParseFlags(flags)
writeHelpForAutocompleteFunc func(string, ...string) error // notsure yet
writeHelpForAutocompleteDebugFunc func(string, ...string) error // notsure yet
- writeHelp func() // notsure yet
+ writeHelpFunc func() error // notsure yet
writeHelpForSubcommand func(string) // notsure yet
examples func() string // some examples
appExit func() // app Exit()
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index 550b63d..2d914fe 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -174,7 +174,7 @@ func Autocomplete(dest any) *Argv {
// this means the user is pressing tab. no longer doing stderr
if me.pb.Cmd == "" {
// me.pp.WriteHelp(os.Stderr)
- me.writeHelp()
+ me.writeHelpFunc()
} else {
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pb.Cmd)
me.writeHelpForSubcommand(me.pb.Cmd)