update Run command
This commit is contained in:
parent
f7d5e2c21e
commit
30a71dc427
13
app.go
13
app.go
@ -196,17 +196,8 @@ func (a *App) Run(arguments []string) (err error) {
|
|||||||
err = set.Parse(arguments[1:])
|
err = set.Parse(arguments[1:])
|
||||||
nerr := normalizeFlags(a.Flags, set)
|
nerr := normalizeFlags(a.Flags, set)
|
||||||
cerr := checkRequiredFlags(a.Flags, set)
|
cerr := checkRequiredFlags(a.Flags, set)
|
||||||
|
|
||||||
context := NewContext(a, set, nil)
|
context := NewContext(a, set, nil)
|
||||||
|
|
||||||
// Define here so it closes over the above variables
|
|
||||||
showErrAndHelp := func(err error) {
|
|
||||||
fmt.Fprintln(a.Writer, err)
|
|
||||||
fmt.Fprintln(a.Writer)
|
|
||||||
ShowAppHelp(context)
|
|
||||||
fmt.Fprintln(a.Writer)
|
|
||||||
}
|
|
||||||
|
|
||||||
if nerr != nil {
|
if nerr != nil {
|
||||||
fmt.Fprintln(a.Writer, nerr)
|
fmt.Fprintln(a.Writer, nerr)
|
||||||
ShowAppHelp(context)
|
ShowAppHelp(context)
|
||||||
@ -219,7 +210,7 @@ func (a *App) Run(arguments []string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cerr != nil {
|
if cerr != nil {
|
||||||
showErrAndHelp(cerr)
|
ShowAppHelp(context)
|
||||||
return cerr
|
return cerr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +336,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cerr != nil {
|
if cerr != nil {
|
||||||
showErrAndHelp(cerr)
|
ShowAppHelp(context)
|
||||||
return cerr
|
return cerr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user