Skip to content

Commit 1f24c66

Browse files
committed
autocomplete: allow searching configuration name
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 648a07c commit 1f24c66

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cli/completer.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,20 @@ func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[st
232232
default:
233233
// Heuristic: autocomplete for the arg for which a list<Arg without id/ids>s API exists
234234
// For example, for zoneid arg, listZones API exists
235-
cutIdx := len(argName)
235+
base := argName
236236
if strings.HasSuffix(argName, "id") {
237-
cutIdx -= 2
237+
base = strings.TrimSuffix(argName, "id")
238238
} else if strings.HasSuffix(argName, "ids") {
239-
cutIdx -= 3
239+
base = strings.TrimSuffix(argName, "ids")
240+
} else if argName == "name" && strings.HasPrefix(apiFound.Noun, "configuration") {
241+
base = "configuration"
242+
}
243+
// Handle common cases where base ends with a vowel and needs "es"
244+
if strings.HasSuffix(base, "s") || strings.HasSuffix(base, "x") || strings.HasSuffix(base, "z") || strings.HasSuffix(base, "ch") || strings.HasSuffix(base, "sh") {
245+
relatedNoun = base + "es"
240246
} else {
247+
relatedNoun = base + "s"
241248
}
242-
relatedNoun = argName[:cutIdx] + "s"
243249
}
244250

245251
config.Debug("Possible related noun for the arg: ", relatedNoun, " and type: ", arg.Type)

0 commit comments

Comments
 (0)