Merge pull request #114 from AudriusButkevicius/shortcut
Add App.RunAndExitOnError shortcut
This commit is contained in:
commit
8c34b12d83
8
app.go
8
app.go
@ -133,6 +133,14 @@ func (a *App) Run(arguments []string) error {
|
|||||||
return nil
|
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
|
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
|
||||||
func (a *App) RunAsSubcommand(ctx *Context) error {
|
func (a *App) RunAsSubcommand(ctx *Context) error {
|
||||||
// append help to commands
|
// append help to commands
|
||||||
|
Loading…
Reference in New Issue
Block a user