Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint + DefaultCommand #662

Merged
merged 6 commits into from
Jan 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down