Merge pull request #662 from OneOfOne/v2

lint + DefaultCommand
This commit is contained in:
Jesse Szwedko 2018-01-28 10:14:10 -08:00 committed by GitHub
commit 1355f91780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

10
app.go
View File

@ -212,7 +212,7 @@ func (a *App) Run(arguments []string) (err error) {
if err != nil {
if a.OnUsageError != nil {
err := a.OnUsageError(context, err, false)
err = a.OnUsageError(context, err, false)
HandleExitCoder(err)
return err
}
@ -480,3 +480,11 @@ func (a *Author) String() string {
return fmt.Sprintf("%v%v", a.Name, e)
}
// DefaultAppComplete returns an ActionFunc to run a default command if non were passed.
// Usage: `app.Action = cli.DefaultCommand("command")`
func DefaultCommand(name string) ActionFunc {
return func(ctx *Context) error {
return ctx.App.Command(name).Run(ctx)
}
}

View File

@ -122,7 +122,7 @@ func (c *Command) Run(ctx *Context) (err error) {
if err != nil {
if c.OnUsageError != nil {
err := c.OnUsageError(context, err, false)
err = c.OnUsageError(context, err, false)
HandleExitCoder(err)
return err
}