Skip to content

Commit a5dbe1a

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/completer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ 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+
relatedNoun += "s"
230+
}
225231
}
226232
case argName == "account":
227233
// Heuristic: user is trying to autocomplete for accounts

0 commit comments

Comments
 (0)