shwstppr commented on code in PR #194:
URL: 
https://github.com/apache/cloudstack-cloudmonkey/pull/194#discussion_r2317776186


##########
cli/completer.go:
##########
@@ -221,7 +221,13 @@ 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)
+                       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") {
+                               relatedNoun += "s"
+                       }

Review Comment:
   @Pearl1594 can we make this a separate method. I gues we are trying to do 
something similar around line 258 as well for autocompleting for name param. 
Maybe we ca reuse?



##########
cli/completer.go:
##########
@@ -221,7 +221,13 @@ 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)
+                       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") {
+                               relatedNoun += "s"
+                       }

Review Comment:
   @Pearl1594 can we make this a separate method. I gues we are trying to do 
something similar around line 258 as well for autocompleting for name param. 
Maybe we can reuse?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to