File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
internal/namespaces/applesilicon/v1alpha1 Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 8
8
"reflect"
9
9
"time"
10
10
11
+ "strings"
12
+
11
13
"github.com/fatih/color"
12
14
"github.com/scaleway/scaleway-cli/v2/internal/core"
13
15
"github.com/scaleway/scaleway-cli/v2/internal/human"
36
38
)
37
39
38
40
func serverCreateBuilder (c * core.Command ) * core.Command {
41
+ c .ArgSpecs .GetByName ("type" ).AutoCompleteFunc = autocompleteServerType
39
42
c .WaitFunc = waitForServerFunc (serverActionCreate )
40
43
return c
41
44
}
@@ -125,3 +128,27 @@ func serverWaitCommand() *core.Command {
125
128
},
126
129
}
127
130
}
131
+
132
+ var completeListTypeServerCache * applesilicon.ListServerTypesResponse
133
+
134
+ func autocompleteServerType (ctx context.Context , prefix string , _ any ) core.AutocompleteSuggestions {
135
+ suggestions := core .AutocompleteSuggestions (nil )
136
+
137
+ client := core .ExtractClient (ctx )
138
+ api := applesilicon .NewAPI (client )
139
+
140
+ if completeListTypeServerCache == nil {
141
+ res , err := api .ListServerTypes (& applesilicon.ListServerTypesRequest {})
142
+ if err != nil {
143
+ return nil
144
+ }
145
+ completeListTypeServerCache = res
146
+ }
147
+
148
+ for _ , serverType := range completeListTypeServerCache .ServerTypes {
149
+ if strings .HasPrefix (serverType .Name , prefix ) {
150
+ suggestions = append (suggestions , serverType .Name )
151
+ }
152
+ }
153
+ return suggestions
154
+ }
You can’t perform that action at this time.
0 commit comments