Add App.RunAndExitOnError shortcut

This commit is contained in:
Audrius Butkevicius 2014-07-13 17:26:20 +01:00
parent d38a3b82a6
commit 449f261ee9

8
app.go
View File

@ -131,6 +131,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