1
0
Fork 0
mirror of https://github.com/spf13/cobra synced 2025-04-01 20:39:12 +00:00
This commit is contained in:
Jonathan Conder 2025-03-12 18:40:21 +13:00 committed by GitHub
commit eaca1fe3bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -360,6 +360,8 @@ func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCo
// the extra added -- is counted as arg.
flagCompletion := true
_ = finalCmd.ParseFlags(append(finalArgs, "--"))
// Reset ArgsLenAtDash.
finalCmd.Flags().Init(finalCmd.Flags().Name(), pflag.ContinueOnError)
newArgCount := finalCmd.Flags().NArg()
// Parse the flags early so we can check if required flags are set