Skip to content

Commit

Permalink
fix(completions): Complete map flags multiple times (spf13#2174)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 authored Jul 28, 2024
1 parent 371ae25 commit 756ba6d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...)
}
Expand Down

0 comments on commit 756ba6d

Please sign in to comment.