@@ -29,7 +29,6 @@ import (
29
29
"time"
30
30
31
31
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
32
- "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1"
33
32
"google.golang.org/grpc"
34
33
"google.golang.org/grpc/credentials/insecure"
35
34
)
@@ -63,8 +62,6 @@ func main() {
63
62
// Create an instance of the gRPC clients.
64
63
client := rpc .NewArduinoCoreServiceClient (conn )
65
64
66
- settingsClient := settings .NewSettingsServiceClient (conn )
67
-
68
65
// Now we can call various methods of the API...
69
66
70
67
// `Version` can be called without any setup or init procedure.
@@ -76,39 +73,39 @@ func main() {
76
73
77
74
// Use SetValue to configure the arduino-cli directories.
78
75
log .Println ("calling SetValue" )
79
- callSetValue (settingsClient )
76
+ callSetValue (client )
80
77
81
- // List all the settings.
82
- log .Println ("calling GetAll ()" )
83
- callGetAll (settingsClient )
78
+ // List all settings
79
+ log .Println ("calling SettingsGetAll ()" )
80
+ callGetAll (client )
84
81
85
82
// Merge applies multiple settings values at once.
86
- log .Println ("calling Merge ()" )
87
- callMerge (settingsClient , `{"foo": {"value": "bar"}, "daemon":{"port":"422"}, "board_manager": {"additional_urls":["https://example.com"]}}` )
83
+ log .Println ("calling SettingsMerge ()" )
84
+ callMerge (client , `{"foo": {"value": "bar"}, "daemon":{"port":"422"}, "board_manager": {"additional_urls":["https://example.com"]}}` )
88
85
89
- log .Println ("calling GetAll ()" )
90
- callGetAll (settingsClient )
86
+ log .Println ("calling SettingsGetAll ()" )
87
+ callGetAll (client )
91
88
92
- log .Println ("calling Merge ()" )
93
- callMerge (settingsClient , `{"foo": {} }` )
89
+ log .Println ("calling SettingsMerge ()" )
90
+ callMerge (client , `{"foo": {} }` )
94
91
95
- log .Println ("calling GetAll ()" )
96
- callGetAll (settingsClient )
92
+ log .Println ("calling SettingsGetAll ()" )
93
+ callGetAll (client )
97
94
98
- log .Println ("calling Merge ()" )
99
- callMerge (settingsClient , `{"foo": "bar" }` )
95
+ log .Println ("calling SettingsMerge ()" )
96
+ callMerge (client , `{"foo": "bar" }` )
100
97
101
98
// Get the value of the foo key.
102
- log .Println ("calling GetValue (foo)" )
103
- callGetValue (settingsClient )
99
+ log .Println ("calling SettingsGetValue (foo)" )
100
+ callGetValue (client )
104
101
105
- // List all the settings.
106
- log .Println ("calling GetAll ()" )
107
- callGetAll (settingsClient )
102
+ // List all settings
103
+ log .Println ("calling SettingsGetAll ()" )
104
+ callGetAll (client )
108
105
109
106
// Write settings to file.
110
107
log .Println ("calling Write()" )
111
- callWrite (settingsClient )
108
+ callWrite (client )
112
109
113
110
// Before we can do anything with the CLI, an "instance" must be created.
114
111
// We keep a reference to the created instance because we will need it to
@@ -121,7 +118,7 @@ func main() {
121
118
122
119
// We set up the proxy and then run the update to verify that the proxy settings are currently used
123
120
log .Println ("calling setProxy" )
124
- callSetProxy (settingsClient )
121
+ callSetProxy (client )
125
122
126
123
// With a brand new instance, the first operation should always be updating
127
124
// the index.
@@ -247,22 +244,21 @@ func callVersion(client rpc.ArduinoCoreServiceClient) {
247
244
log .Printf ("arduino-cli version: %v" , versionResp .GetVersion ())
248
245
}
249
246
250
- func callSetValue (client settings. SettingsServiceClient ) {
251
- _ , err := client .SetValue (context .Background (),
252
- & settings. SetValueRequest {
247
+ func callSetValue (client rpc. ArduinoCoreServiceClient ) {
248
+ _ , err := client .SettingsSetValue (context .Background (),
249
+ & rpc. SettingsSetValueRequest {
253
250
Key : "directories" ,
254
251
JsonData : `{"data": "` + dataDir + `", "downloads": "` + path .Join (dataDir , "staging" ) + `", "user": "` + path .Join (dataDir , "sketchbook" ) + `"}` ,
255
252
})
256
253
257
254
if err != nil {
258
255
log .Fatalf ("Error setting settings value: %s" , err )
259
-
260
256
}
261
257
}
262
258
263
- func callSetProxy (client settings. SettingsServiceClient ) {
264
- _ , err := client .SetValue (context .Background (),
265
- & settings. SetValueRequest {
259
+ func callSetProxy (client rpc. ArduinoCoreServiceClient ) {
260
+ _ , err := client .SettingsSetValue (context .Background (),
261
+ & rpc. SettingsSetValueRequest {
266
262
Key : "network.proxy" ,
267
263
JsonData : `"http://localhost:3128"` ,
268
264
})
@@ -272,9 +268,9 @@ func callSetProxy(client settings.SettingsServiceClient) {
272
268
}
273
269
}
274
270
275
- func callUnsetProxy (client settings. SettingsServiceClient ) {
276
- _ , err := client .SetValue (context .Background (),
277
- & settings. SetValueRequest {
271
+ func callUnsetProxy (client rpc. ArduinoCoreServiceClient ) {
272
+ _ , err := client .SettingsSetValue (context .Background (),
273
+ & rpc. SettingsSetValueRequest {
278
274
Key : "network.proxy" ,
279
275
JsonData : `""` ,
280
276
})
@@ -284,9 +280,9 @@ func callUnsetProxy(client settings.SettingsServiceClient) {
284
280
}
285
281
}
286
282
287
- func callMerge (client settings. SettingsServiceClient , jsonData string ) {
288
- _ , err := client .Merge (context .Background (),
289
- & settings. MergeRequest {
283
+ func callMerge (client rpc. ArduinoCoreServiceClient , jsonData string ) {
284
+ _ , err := client .SettingsMerge (context .Background (),
285
+ & rpc. SettingsMergeRequest {
290
286
JsonData : jsonData ,
291
287
})
292
288
@@ -295,9 +291,9 @@ func callMerge(client settings.SettingsServiceClient, jsonData string) {
295
291
}
296
292
}
297
293
298
- func callGetValue (client settings. SettingsServiceClient ) {
299
- getValueResp , err := client .GetValue (context .Background (),
300
- & settings. GetValueRequest {
294
+ func callGetValue (client rpc. ArduinoCoreServiceClient ) {
295
+ getValueResp , err := client .SettingsGetValue (context .Background (),
296
+ & rpc. SettingsGetValueRequest {
301
297
Key : "foo" ,
302
298
})
303
299
@@ -308,8 +304,8 @@ func callGetValue(client settings.SettingsServiceClient) {
308
304
log .Printf ("Value: %s: %s" , getValueResp .GetKey (), getValueResp .GetJsonData ())
309
305
}
310
306
311
- func callGetAll (client settings. SettingsServiceClient ) {
312
- getAllResp , err := client .GetAll (context .Background (), & settings. GetAllRequest {})
307
+ func callGetAll (client rpc. ArduinoCoreServiceClient ) {
308
+ getAllResp , err := client .SettingsGetAll (context .Background (), & rpc. SettingsGetAllRequest {})
313
309
314
310
if err != nil {
315
311
log .Fatalf ("Error getting settings: %s" , err )
@@ -318,10 +314,10 @@ func callGetAll(client settings.SettingsServiceClient) {
318
314
log .Printf ("Settings: %s" , getAllResp .GetJsonData ())
319
315
}
320
316
321
- func callWrite (client settings. SettingsServiceClient ) {
322
- _ , err := client .Write (context .Background (),
323
- & settings. WriteRequest {
324
- FilePath : path .Join (dataDir , "written-settings.yml " ),
317
+ func callWrite (client rpc. ArduinoCoreServiceClient ) {
318
+ _ , err := client .SettingsWrite (context .Background (),
319
+ & rpc. SettingsWriteRequest {
320
+ FilePath : path .Join (dataDir , "written-rpc.Settingsyml " ),
325
321
})
326
322
327
323
if err != nil {
0 commit comments