fix(completions): Complete map flags multiple times (#2174)

This commit is contained in:
Gabe Cook 2024-07-28 11:18:07 -05:00 committed by GitHub
parent 371ae25d2c
commit 756ba6dad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)...)
} }