lint + DefaultCommand
This commit is contained in:
parent
50a0fdeea6
commit
163f247519
10
app.go
10
app.go
@ -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 = DefaultCommand("command")`
|
||||
func DefaultCommand(name string) ActionFunc {
|
||||
return func(ctx *Context) error {
|
||||
return ctx.App.Command(name).Run(ctx)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user