Merge pull request #65 from tjarratt/custom-help-printer

Add a way to override the app help printer
main
Jeremy Saenz 11 years ago
commit 8242fd818c

@ -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")
}
}

@ -59,8 +59,9 @@ var helpCommand = Command{
} }
// Prints help for the App // Prints help for the App
var HelpPrinter = printHelp
func ShowAppHelp(c *Context) { func ShowAppHelp(c *Context) {
printHelp(AppHelpTemplate, c.App) HelpPrinter(AppHelpTemplate, c.App)
} }
// Prints help for the given command // Prints help for the given command

Loading…
Cancel
Save