diff options
| -rw-r--r-- | interface.go | 22 | ||||
| -rw-r--r-- | structs.go | 2 | ||||
| -rw-r--r-- | theMagicOfAutocomplete.go | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/interface.go b/interface.go index 166eb14..4e27dd8 100644 --- a/interface.go +++ b/interface.go @@ -29,6 +29,10 @@ type writeHelpForAutocompleteDebugI interface { WriteHelpForAutocompleteDebug(string, ...string) error } +type writeHelpForSubcommandI interface { + WriteHelpForSubcommand(cmd string) error +} + type writeHelpI interface { WriteHelp() error } @@ -113,6 +117,12 @@ func findAppInfo(tmp interface{}) { helpWriteHelpForAutocompleteDebug() } + if tmp, ok := tmp.(writeHelpForSubcommandI); ok { + me.writeHelpForSubcommandFunc = tmp.WriteHelpForSubcommand + } else { + helpWriteHelpForSubcommand() + } + if tmp, ok := tmp.(writeHelpI); ok { me.writeHelpFunc = tmp.WriteHelp } else { @@ -173,6 +183,18 @@ func findAppInfo(tmp interface{}) { } } +func helpWriteHelpForSubcommand() { + log.Info("") + log.Info("// add this funcgion: this will print the help") + log.Info("func (args) WriteHelpForSubcommand() error {") + log.Info(" me.pp.WriteHelpForSubcommand(os.Stderr, me.argv.Cmd)") + log.Info(" return nil") + log.Info("}") + log.Info("") + log.Info("cp ~/go/src/go.wit.com/apps/forge/argv.template.go .") + panic("copy the argv.template.go file from forge") +} + func helpWriteHelp() { log.Info("") log.Info("// add this funcgion: this will print the help") @@ -17,7 +17,7 @@ type AutoArgs struct { writeHelpForAutocompleteFunc func(string, ...string) error // notsure yet writeHelpForAutocompleteDebugFunc func(string, ...string) error // notsure yet writeHelpFunc func() error // notsure yet - writeHelpForSubcommand func(string) // notsure yet + writeHelpForSubcommandFunc func(string) error // notsure yet examples func() string // some examples appExit func() // app Exit() buildtime func() (string, string) // some examples diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index dc3efb4..7a3bc59 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -178,7 +178,7 @@ func Autocomplete(dest any) *Argv { me.writeHelpFunc() } else { // me.pp.WriteHelpForSubcommand(os.Stderr, me.pb.Cmd) - me.writeHelpForSubcommand(me.pb.Cmd) + me.writeHelpForSubcommandFunc(me.pb.Cmd) } } } else { |
