diff --git a/command.go b/command.go index 0de3ec80..43916321 100644 --- a/command.go +++ b/command.go @@ -1217,6 +1217,9 @@ Simply type ` + c.Name() + ` help [path to command] for full details.`, pflag.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) }, Run: func(c *Command, args []string) { cmd, _, e := c.Root().Find(args)