1
0
Fork 0
mirror of https://github.com/spf13/cobra synced 2025-04-07 07:19:16 +00:00
This commit is contained in:
Jonathan Conder 2025-03-12 13:33:35 +13:00 committed by GitHub
commit 6eef0f1aea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -359,7 +359,9 @@ func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCo
// if -- was already set or interspersed is false and there is already one arg then
// the extra added -- is counted as arg.
flagCompletion := true
_ = finalCmd.ParseFlags(append(finalArgs, "--"))
extendedArgs := make([]string, 0, len(finalArgs)+1)
extendedArgs = append(append(extendedArgs, finalArgs...), "--")
_ = finalCmd.ParseFlags(extendedArgs)
newArgCount := finalCmd.Flags().NArg()
// Parse the flags early so we can check if required flags are set