Skip to content

Commit f2ef711

Browse files
committed
Fix auto-completion logic for APIs that end with 'y'
1 parent 531d8da commit f2ef711

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cli/completer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[st
221221
// Heuristic: user is trying to autocomplete for id/ids arg for a list API
222222
relatedNoun = apiFound.Noun
223223
if apiFound.Verb != "list" {
224-
relatedNoun += "s"
224+
config.Debug("relatedNoun before suffix check: ", relatedNoun)
225+
if strings.HasSuffix(relatedNoun, "y") && len(relatedNoun) > 1 && !strings.ContainsAny(string(relatedNoun[len(relatedNoun)-2]), "aeiou") {
226+
// Handle words ending in consonant + y (e.g., policy -> policies)
227+
relatedNoun = relatedNoun[:len(relatedNoun)-1] + "ies"
228+
} else if !strings.HasSuffix(relatedNoun, "ies") {
229+
// Check if relatedNoun already ends with "ies", don't add "s"
230+
relatedNoun += "s"
231+
}
225232
}
226233
case argName == "account":
227234
// Heuristic: user is trying to autocomplete for accounts

0 commit comments

Comments
 (0)