diff --git a/command.go b/command.go index 9a7d23b..6a6674a 100644 --- a/command.go +++ b/command.go @@ -444,9 +444,11 @@ func Execute(ctx context.Context, w io.Writer, root *Command, args []string, env return 1 } - if err := current.PreSubCommandRun(ctx, current.Config, current); err != nil { - _, _ = fmt.Fprintln(w, err.Error()) - return 1 + if current.PreSubCommandRun != nil { + if err := current.PreSubCommandRun(ctx, current.Config, current); err != nil { + _, _ = fmt.Fprintln(w, err.Error()) + return 1 + } } }