diff --git a/app_test.go b/app_test.go index 50f263383c..f329b91361 100644 --- a/app_test.go +++ b/app_test.go @@ -225,3 +225,22 @@ func TestApp_BeforeFunc(t *testing.T) { } } + +func TestAppHelpPrinter(t *testing.T) { + oldPrinter := cli.HelpPrinter + defer func() { + cli.HelpPrinter = oldPrinter + }() + + var wasCalled = false + cli.HelpPrinter = func(template string, data interface{}) { + wasCalled = true + } + + app := cli.NewApp() + app.Run([]string{"-h"}) + + if wasCalled == false { + t.Errorf("Help printer expected to be called, but was not") + } +} diff --git a/help.go b/help.go index 46f77c95fd..d13b89b7d2 100644 --- a/help.go +++ b/help.go @@ -69,8 +69,9 @@ var helpCommand = Command{ } // Prints help for the App +var HelpPrinter = printHelp func ShowAppHelp(c *Context) { - printHelp(AppHelpTemplate, c.App) + HelpPrinter(AppHelpTemplate, c.App) } // Prints help for the given command