From ef1328f8cf91b17683b544369bd1c07841b7bb8e Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Fri, 14 Jul 2023 00:38:29 +0900 Subject: [PATCH] call Root PersistentPreRun on Completion Command --- completions.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/completions.go b/completions.go index 92e17f6..23d09bc 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)