From 0a21a9fd7ac1044f7420f1f2e03554c0198ed5f3 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 8 Jun 2022 12:29:57 -0500 Subject: [PATCH] :bug: Remove .Value, .Val, and .V from shell completion --- internal/config/values.go | 2 ++ internal/visitor/find_args.go | 5 +++++ internal/visitor/find_args_test.go | 1 + 3 files changed, 8 insertions(+) diff --git a/internal/config/values.go b/internal/config/values.go index f60bb22..e3305f9 100644 --- a/internal/config/values.go +++ b/internal/config/values.go @@ -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) { diff --git a/internal/visitor/find_args.go b/internal/visitor/find_args.go index f8828e9..0cb1bc7 100644 --- a/internal/visitor/find_args.go +++ b/internal/visitor/find_args.go @@ -75,6 +75,11 @@ outer: continue outer } } + for _, reserved := range config.ReservedKeys { + if k == reserved { + continue outer + } + } result = append(result, k+"=") } return result diff --git a/internal/visitor/find_args_test.go b/internal/visitor/find_args_test.go index 12af56b..47b3e42 100644 --- a/internal/visitor/find_args_test.go +++ b/internal/visitor/find_args_test.go @@ -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) {