Skip to content
Myr

Delete checkHelpFunc

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 10f6b9d · Browse files · 1 file+7 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−19 removed

  • other:+7 added−19 removed

1 file+7 added−19 removed

modified:command.go+7 added-19 removed
213 unmodified lines
214func (c *Command) UsageFunc() (f func(*Command) error) {215 if c.usageFunc != nil {216 return c.usageFunc217 }218218 if c.HasParent() {220 return c.parent.UsageFunc()219 return c.Parent().UsageFunc()220 }221 return func(c *Command) error {222 c.mergePersistentFlags()223 err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
13 unmodified lines
237238// HelpFunc returns either the function set by SetHelpFunc for this command239// or a parent, or it returns a function with default help behavior.240func (c *Command) HelpFunc() func(*Command, []string) {242 if helpFunc := c.checkHelpFunc(); helpFunc != nil {243 return helpFunc241 if c.helpFunc != nil {242 return c.helpFunc243 }244 if c.HasParent() {245 return c.Parent().HelpFunc()246 }245 return func(*Command, []string) {247 return func(c *Command, a []string) {248 c.mergePersistentFlags()249 err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)250 if err != nil {251 c.Println(err)252 }253 }254}255254// checkHelpFunc checks if there is helpFunc in ancestors of c.255func (c *Command) checkHelpFunc() func(*Command, []string) {256 if c == nil {257 return nil258 }259 if c.helpFunc != nil {260 return c.helpFunc261 }262 if c.HasParent() {263 return c.parent.checkHelpFunc()264 }265 return nil266}267256// Help puts out the help for the command.257// Used when a user calls help [command].258// Can be defined by user by overriding HelpFunc.259func (c *Command) Help() error {
977 unmodified lines