diff --git a/completions.go b/completions.go index 92e17f68..23d09bc7 100644 --- a/completions.go +++ b/completions.go @@ -689,6 +689,9 @@ See each sub-command's help for details on how to use the generated script. flag.Annotations[BashCompOneRequiredFlag] = []string{"false"} } }) + // Adding PersistentPreRun on sub-commands prevents root's PersistentPreRun from being called. + // So it is intentionally called here. + cmd.Root().PersistentPreRun(cmd.Root(), args) }, } c.AddCommand(completionCmd)