Fix:(issue_1094) Dont execute Before/After handlers during shell completion
This commit is contained in:
8
app.go
8
app.go
@@ -304,7 +304,7 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if a.After != nil {
|
||||
if a.After != nil && !cCtx.shellComplete {
|
||||
defer func() {
|
||||
if afterErr := a.After(cCtx); afterErr != nil {
|
||||
if err != nil {
|
||||
@@ -332,7 +332,7 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
|
||||
return cerr
|
||||
}
|
||||
|
||||
if a.Before != nil {
|
||||
if a.Before != nil && !cCtx.shellComplete {
|
||||
beforeErr := a.Before(cCtx)
|
||||
if beforeErr != nil {
|
||||
a.handleExitCoder(cCtx, beforeErr)
|
||||
@@ -499,7 +499,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
||||
return cerr
|
||||
}
|
||||
|
||||
if a.After != nil {
|
||||
if a.After != nil && !cCtx.shellComplete {
|
||||
defer func() {
|
||||
afterErr := a.After(cCtx)
|
||||
if afterErr != nil {
|
||||
@@ -513,7 +513,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
||||
}()
|
||||
}
|
||||
|
||||
if a.Before != nil {
|
||||
if a.Before != nil && !cCtx.shellComplete {
|
||||
beforeErr := a.Before(cCtx)
|
||||
if beforeErr != nil {
|
||||
a.handleExitCoder(cCtx, beforeErr)
|
||||
|
Reference in New Issue
Block a user