Skip to content

Commit 69222b4

Browse files
committed
Add enum autocomplete support for internetprotocol parameter in createVPCOffering
1 parent 17afc27 commit 69222b4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cli/completer.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ func inArray(s string, array []string) bool {
107107
func lastString(array []string) string {
108108
return array[len(array)-1]
109109
}
110+
func enumAutocomplete(argName string) []string {
111+
switch argName {
112+
case "internetprotocol":
113+
return []string{"ipv4", "dualstack"}
114+
}
115+
return nil
116+
}
110117

111118
type argOption struct {
112119
Value string
@@ -412,7 +419,18 @@ func (t *autoCompleter) Do(line []rune, pos int) (options [][]rune, offset int)
412419
}
413420
return
414421
}
415-
422+
argName := strings.Replace(arg.Name, "=", "", -1)
423+
enumValues := enumAutocomplete(argName)
424+
if enumValues != nil {
425+
offset = 0
426+
for _, val := range enumValues {
427+
if strings.HasPrefix(val, argInput) {
428+
options = append(options, []rune(val[len(argInput):]+" "))
429+
offset = len(argInput)
430+
}
431+
}
432+
return
433+
}
416434
autocompleteAPI := findAutocompleteAPI(arg, apiFound, apiMap)
417435
if autocompleteAPI == nil {
418436
return nil, 0

0 commit comments

Comments
 (0)