Also show help if App/Command Before produces error.

This commit is contained in:
Gregor Noczinski 2015-12-25 22:08:22 +01:00
parent f90cd56647
commit f3c8e07836
2 changed files with 6 additions and 0 deletions

3
app.go
View File

@ -164,6 +164,9 @@ func (a *App) Run(arguments []string) (err error) {
if a.Before != nil { if a.Before != nil {
err := a.Before(context) err := a.Before(context)
if err != nil { if err != nil {
fmt.Fprintln(a.Writer, err)
fmt.Fprintln(a.Writer)
ShowAppHelp(context)
return err return err
} }
} }

View File

@ -149,6 +149,9 @@ func (c Command) Run(ctx *Context) (err error) {
if c.Before != nil { if c.Before != nil {
err := c.Before(context) err := c.Before(context)
if err != nil { if err != nil {
fmt.Fprintln(ctx.App.Writer, err)
fmt.Fprintln(ctx.App.Writer)
ShowCommandHelp(ctx, c.Name)
return err return err
} }
} }