call Root PersitentPreRun on HelpCommand

This commit is contained in:
Jun Nishimura 2023-07-14 00:38:08 +09:00
parent 94a3cb1439
commit 2d1eeaf169

View file

@ -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)