Commit 103dd8de authored by per1234's avatar per1234 Committed by Massimiliano Pippi

[skip changelog] Demonstrate gRPC interface's LibraryResolveDependencies...

[skip changelog] Demonstrate gRPC interface's LibraryResolveDependencies method in client_example (#552)

parent 23e4d707
......@@ -6,4 +6,4 @@ require (
github.com/arduino/arduino-cli v0.0.0-20200109150215-ffa84fdaab21
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282 // indirect
google.golang.org/grpc v1.23.0
)
)
\ No newline at end of file
......@@ -164,6 +164,10 @@ func main() {
log.Println("calling LibrarySearch(audio)")
callLibSearch(client, instance)
// List the dependencies of the ArduinoIoTCloud library
log.Println("calling LibraryResolveDependencies(ArduinoIoTCloud)")
callLibraryResolveDependencies(client, instance)
// List installed libraries
log.Println("calling LibraryList")
callLibList(client, instance)
......@@ -734,6 +738,26 @@ func callLibSearch(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
}
}
func callLibraryResolveDependencies(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
libraryResolveDependenciesResp, err := client.LibraryResolveDependencies(context.Background(),
&rpc.LibraryResolveDependenciesReq{
Instance: instance,
Name: "ArduinoIoTCloud",
})
if err != nil {
log.Fatalf("Error listing library dependencies: %s", err)
}
for _, resp := range libraryResolveDependenciesResp.GetDependencies() {
log.Printf("Dependency Name: %s", resp.GetName())
log.Printf("Version Required: %s", resp.GetVersionRequired())
if resp.GetVersionInstalled() != "" {
log.Printf("Version Installed: %s\n", resp.GetVersionInstalled())
}
}
}
func callLibList(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
libLstResp, err := client.LibraryList(context.Background(),
&rpc.LibraryListReq{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment