From dca177c384c35776b499012316b5363475499cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Castan=CC=83e=CC=81?= Date: Sat, 10 Jan 2015 00:51:06 +0100 Subject: [PATCH] After handler brought up to speed. As discussed in issue #151, I modified the implementation to be simpler. I checked how to propagate err, being done with a scope trick. From our deferred function we cannot return a new value, so we override the "default" return value (err), declared on functions' declarations. Check this StackOverflow for more info: http://stackoverflow.com/a/19934989 --- app.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app.go b/app.go index 69aa95b..f01ae42 100644 --- a/app.go +++ b/app.go @@ -77,8 +77,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 +func (a *App) Run(arguments []string) (err error) { if HelpPrinter == nil { defer func() { HelpPrinter = nil @@ -184,8 +183,7 @@ func (a *App) RunAndExitOnError() { } // Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags -func (a *App) RunAsSubcommand(ctx *Context) error { - var err error +func (a *App) RunAsSubcommand(ctx *Context) (err error) { // append help to commands if len(a.Commands) > 0 { if a.Command(helpCommand.Name) == nil && !a.HideHelp {