Merge pull request #114 from AudriusButkevicius/shortcut

Add App.RunAndExitOnError shortcut
This commit is contained in:
Jeremy Saenz 2014-07-15 12:30:47 -07:00
commit 8c34b12d83

8
app.go
View File

@ -133,6 +133,14 @@ func (a *App) Run(arguments []string) error {
return nil
}
// Another entry point to the cli app, takes care of passing arguments and error handling
func (a *App) RunAndExitOnError() {
if err := a.Run(os.Args); err != nil {
os.Stderr.WriteString(fmt.Sprintln(err))
os.Exit(1)
}
}
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
func (a *App) RunAsSubcommand(ctx *Context) error {
// append help to commands