@@ -13,6 +13,31 @@ import (
13
13
"github.com/urfave/cli/v2"
14
14
)
15
15
16
+ type mindFlagsCompleter struct {
17
+ base readline.AutoCompleter
18
+ }
19
+
20
+ func (f * mindFlagsCompleter ) Do (line []rune , pos int ) ([][]rune , int ) {
21
+ // Get the portion of the line up to the cursor and split to tokens
22
+ origInput := string (line [:pos ])
23
+ tokens := strings .Fields (origInput )
24
+ filtered := make ([]string , 0 , len (tokens ))
25
+ for _ , tok := range tokens {
26
+ // Skip flag tokens
27
+ if strings .HasPrefix (tok , "-" ) {
28
+ continue
29
+ }
30
+ filtered = append (filtered , tok )
31
+ }
32
+ sanitized := strings .Join (filtered , " " )
33
+ // Add additional space if had one on original line
34
+ if len (origInput ) > 0 && origInput [len (origInput )- 1 ] == ' ' {
35
+ sanitized += " "
36
+ }
37
+
38
+ return f .base .Do ([]rune (sanitized ), len ([]rune (sanitized )))
39
+ }
40
+
16
41
func (s * Action ) entriesForCompleter (ctx context.Context ) ([]* readline.PrefixCompleter , error ) {
17
42
args := []* readline.PrefixCompleter {}
18
43
list , err := s .Store .List (ctx , tree .INF )
@@ -144,7 +169,7 @@ READ:
144
169
// the list of secrets may have changed, e.g. due to
145
170
// the user adding a new secret.
146
171
cfg := rl .GetConfig ()
147
- cfg .AutoComplete = s .prefixCompleter (c )
172
+ cfg .AutoComplete = & mindFlagsCompleter { base : s .prefixCompleter (c )}
148
173
if err := rl .SetConfig (cfg ); err != nil {
149
174
debug .Log ("Failed to set readline config: %s" , err )
150
175
0 commit comments