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
This commit is contained in:
parent
4ab12cd639
commit
dca177c384
6
app.go
6
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
|
// 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 {
|
func (a *App) Run(arguments []string) (err error) {
|
||||||
var err error
|
|
||||||
if HelpPrinter == nil {
|
if HelpPrinter == nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
HelpPrinter = nil
|
HelpPrinter = nil
|
||||||
@ -184,8 +183,7 @@ func (a *App) RunAndExitOnError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
|
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
|
||||||
func (a *App) RunAsSubcommand(ctx *Context) error {
|
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
||||||
var err error
|
|
||||||
// append help to commands
|
// append help to commands
|
||||||
if len(a.Commands) > 0 {
|
if len(a.Commands) > 0 {
|
||||||
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
|
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
|
||||||
|
Loading…
Reference in New Issue
Block a user