From 4ab12cd639d80ed43e78a02ef62a8073f597192f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Castan=CC=83e=CC=81?= Date: Sat, 10 Jan 2015 00:44:37 +0100 Subject: [PATCH] jszwedko's suggestion done --- app.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app.go b/app.go index f400ab9..69aa95b 100644 --- a/app.go +++ b/app.go @@ -78,6 +78,7 @@ func NewApp() *App { // Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination func (a *App) Run(arguments []string) error { + var err error if HelpPrinter == nil { defer func() { HelpPrinter = nil @@ -146,11 +147,10 @@ func (a *App) Run(arguments []string) error { if a.After != nil { defer func() { - aferr := a.After(context) - // check Action error to avoid shadowing - if err == nil { - err = aferr - } + // err is always nil here. + // There is a check to see if it is non-nil + // just few lines before. + err = a.After(context) }() } @@ -184,7 +184,8 @@ func (a *App) RunAndExitOnError() { } // Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags -func (a *App) RunAsSubcommand(ctx *Context) (err error) { +func (a *App) RunAsSubcommand(ctx *Context) error { + var err error // append help to commands if len(a.Commands) > 0 { if a.Command(helpCommand.Name) == nil && !a.HideHelp { @@ -240,11 +241,10 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) { if a.After != nil { defer func() { - aferr := a.After(context) - // check Action error to avoid shadowing - if err == nil { - err = aferr - } + // err is always nil here. + // There is a check to see if it is non-nil + // just few lines before. + err = a.After(context) }() }