From 2d1eeaf16971bf69cff27d8eb9ee52797f59115d Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Fri, 14 Jul 2023 00:38:08 +0900 Subject: [PATCH] call Root PersitentPreRun on HelpCommand --- command.go | 3 +++ 1 file changed, 3 insertions(+) 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)