Add a way to override the app help printer

Fixes #64
main
Tim Jarratt 10 years ago
parent c606efc92b
commit 58bfabca6d

@ -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
var HelpPrinter = printHelp
func ShowAppHelp(c *Context) {
printHelp(AppHelpTemplate, c.App)
HelpPrinter(AppHelpTemplate, c.App)
}
// Prints help for the given command

Loading…
Cancel
Save