This is an automated email from the ASF dual-hosted git repository. pearl11594 pushed a commit to branch fix-autocomplete-apis-ending-in-ies in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
commit d252f0291de7d670d3b9b85fdc6045a9ab36e83b Author: Pearl Dsilva <[email protected]> AuthorDate: Tue Sep 2 15:01:51 2025 -0400 Fix auto-completion logic for APIs that end with 'y' --- cli/completer.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/completer.go b/cli/completer.go index 755cc7f..71f6856 100644 --- a/cli/completer.go +++ b/cli/completer.go @@ -221,7 +221,15 @@ func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[st // Heuristic: user is trying to autocomplete for id/ids arg for a list API relatedNoun = apiFound.Noun if apiFound.Verb != "list" { - relatedNoun += "s" + config.Debug("relatedNoun before suffix check: ", relatedNoun) + // Apply proper pluralization logic + if strings.HasSuffix(relatedNoun, "y") && len(relatedNoun) > 1 && !strings.ContainsAny(string(relatedNoun[len(relatedNoun)-2]), "aeiou") { + // Handle words ending in consonant + y (e.g., policy -> policies) + relatedNoun = relatedNoun[:len(relatedNoun)-1] + "ies" + } else if !strings.HasSuffix(relatedNoun, "ies") { + // Check if relatedNoun already ends with "ies", don't add "s" + relatedNoun += "s" + } } case argName == "account": // Heuristic: user is trying to autocomplete for accounts
