You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "winterhazel (via GitHub)" <gi...@apache.org> on 2025/02/15 19:29:59 UTC

Re: [PR] Fix usagetype parameter autocomplete [cloudstack-cloudmonkey]

winterhazel commented on code in PR #156:
URL: https://github.com/apache/cloudstack-cloudmonkey/pull/156#discussion_r1957178119


##########
cli/completer.go:
##########
@@ -398,15 +406,23 @@ func (t *autoCompleter) Do(line []rune, pos int) (options [][]rune, offset int)
 				response, _ := cmd.NewAPIRequest(request, autocompleteAPI.Name, autocompleteAPIArgs, false)
 				t.Config.StopSpinner(spinner)
 
-				hasID := strings.HasSuffix(arg.Name, "id=") || strings.HasSuffix(arg.Name, "ids=")
+				hasID := strings.HasSuffix(arg.Name, "id=") || strings.HasSuffix(arg.Name, "ids=") || autocompleteAPI.Name == "listUsageTypes"
 				argOptions = buildArgOptions(response, hasID)
 			}
 
 			filteredOptions := []argOption{}
 			if len(argOptions) > 0 {
-				sort.Slice(argOptions, func(i, j int) bool {
-					return argOptions[i].Value < argOptions[j].Value
-				})
+				if isNumeric(argOptions[0].Value) {

Review Comment:
   Maybe check `arg.Name` instead (or `autocompleteAPI.Name`) so that other APIs are not affected?



-- 
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: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org