mirror of
https://github.com/spf13/cobra.git
synced 2024-11-15 01:38:17 -07:00
fix(completions): Complete map flags multiple times (#2174)
This commit is contained in:
parent
371ae25d2c
commit
756ba6dad6
@ -401,8 +401,9 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
|||||||
doCompleteFlags := func(flag *pflag.Flag) {
|
doCompleteFlags := func(flag *pflag.Flag) {
|
||||||
if !flag.Changed ||
|
if !flag.Changed ||
|
||||||
strings.Contains(flag.Value.Type(), "Slice") ||
|
strings.Contains(flag.Value.Type(), "Slice") ||
|
||||||
strings.Contains(flag.Value.Type(), "Array") {
|
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.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
|
// we suggest it as a completion
|
||||||
completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
|
completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user