mirror of
https://github.com/spf13/cobra
synced 2025-04-01 20:39:12 +00:00
fix: Prevent getCompletions from modifying os.Args
This commit is contained in:
parent
ceb39aba25
commit
1b401ede18
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue