File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
internal/namespaces/product_catalog/v2alpha1 Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -5,5 +5,13 @@ import "github.com/scaleway/scaleway-cli/v2/core"
55func GetCommands () * core.Commands {
66 cmds := GetGeneratedCommands ()
77
8+ cmds .MustFind ("product-catalog" , "product" , "list" ).Override (productListBuilder )
9+
810 return cmds
911}
12+
13+ func productListBuilder (c * core.Command ) * core.Command {
14+ c .ArgSpecs .GetByName ("product-types.{index}" ).AutoCompleteFunc = autocompleteProductType
15+
16+ return c
17+ }
Original file line number Diff line number Diff line change 1+ package product_catalog
2+
3+ import (
4+ "context"
5+
6+ "github.com/scaleway/scaleway-cli/v2/core"
7+ product_catalog "github.com/scaleway/scaleway-sdk-go/api/product_catalog/v2alpha1"
8+ )
9+
10+ // Caching ListPublicCatalogProductsRequestProductType values for shell completion
11+ var completeProductTypeCache []product_catalog.ListPublicCatalogProductsRequestProductType
12+
13+ func autocompleteProductType (ctx context.Context , _ string , _ any ) core.AutocompleteSuggestions {
14+ suggestions := core .AutocompleteSuggestions (nil )
15+
16+ if len (completeProductTypeCache ) == 0 {
17+ var productTypes product_catalog.ListPublicCatalogProductsRequestProductType
18+ completeProductTypeCache = productTypes .Values ()
19+ }
20+
21+ for _ , productType := range completeProductTypeCache {
22+ suggestions = append (suggestions , string (productType ))
23+ }
24+
25+ return suggestions
26+ }
You can’t perform that action at this time.
0 commit comments