Skip to content

Commit

Permalink
🐛 Remove .Value, .Val, and .V from shell completion
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 8, 2022
1 parent 0b2f5a9 commit 0a21a9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/config/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package config

import "strings"

var ReservedKeys = []string{"Value", "Val", "V"}

type Values map[string]any

func (values Values) Fill(rawValues map[string]string) {
Expand Down
5 changes: 5 additions & 0 deletions internal/visitor/find_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ outer:
continue outer
}
}
for _, reserved := range config.ReservedKeys {
if k == reserved {
continue outer
}
}
result = append(result, k+"=")
}
return result
Expand Down
1 change: 1 addition & 0 deletions internal/visitor/find_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestFindArgs_Values(t *testing.T) {
{"simple", fields{valMap: map[string]struct{}{"a": {}}}, []string{"a="}},
{"nested", fields{valMap: map[string]struct{}{"a.b": {}}}, []string{"a.b="}},
{"duplicate", fields{conf: config.Config{Values: map[string]any{"b": "b"}}, valMap: map[string]struct{}{"b": {}}}, []string{}},
{"reserved", fields{valMap: map[string]struct{}{"Value": {}}}, []string{}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 0a21a9f

Please sign in to comment.