mirror of
https://github.com/spf13/cobra
synced 2024-11-05 05:17:12 +00:00
fix(completions): Complete map flags multiple times (#2174)
This commit is contained in:
parent
371ae25d2c
commit
756ba6dad6
1 changed files with 3 additions and 2 deletions
|
@ -401,8 +401,9 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
|||
doCompleteFlags := func(flag *pflag.Flag) {
|
||||
if !flag.Changed ||
|
||||
strings.Contains(flag.Value.Type(), "Slice") ||
|
||||
strings.Contains(flag.Value.Type(), "Array") {
|
||||
// If the flag is not already present, or if it can be specified multiple times (Array or Slice)
|
||||
strings.Contains(flag.Value.Type(), "Array") ||
|
||||
strings.HasPrefix(flag.Value.Type(), "stringTo") {
|
||||
// If the flag is not already present, or if it can be specified multiple times (Array, Slice, or stringTo)
|
||||
// we suggest it as a completion
|
||||
completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue