Skip to content

Commit afe0a4f

Browse files
committed
Small fix to daemon/client
1 parent 8bc318e commit afe0a4f

File tree

1 file changed

+26
-41
lines changed

1 file changed

+26
-41
lines changed

daemon/client/client.go

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
//
2+
// This file is part of arduino-cli.
3+
//
4+
// Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of arduino-cli.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
118
package main
219

320
import (
@@ -187,61 +204,29 @@ func main() {
187204
}
188205
}
189206

190-
searchRespStream, err := client.PlatformSearch(context.Background(), &rpc.PlatformSearchReq{
207+
searchResp, err := client.PlatformSearch(context.Background(), &rpc.PlatformSearchReq{
191208
Instance: instance,
192209
SearchArgs: "uno",
193210
})
194211
if err != nil {
195212
fmt.Printf("Search error: %s\n", err)
196213
os.Exit(1)
197214
}
198-
for {
199-
searchResp, err := searchRespStream.Recv()
200-
if err == io.EOF {
201-
break
202-
}
203-
if err != nil {
204-
fmt.Printf("Compile error: %s\n", err)
205-
os.Exit(1)
206-
}
207-
if searchResp.GetTaskProgress() != nil {
208-
fmt.Printf(">> TASK: %s\n", searchResp.GetTaskProgress())
209-
}
210-
if searchResp.GetSearchOutput() != nil {
211-
serchedOutput := searchResp.GetSearchOutput()
212-
for _, outsearch := range serchedOutput {
213-
fmt.Printf(">> OUTPUT: ID: %s\t Version: %s\t name: %s\n", outsearch.GetID(), outsearch.GetVersion(), outsearch.GetName())
214-
}
215-
216-
}
215+
serchedOutput := searchResp.GetSearchOutput()
216+
for _, outsearch := range serchedOutput {
217+
fmt.Printf(">> SEARCH: %+v\n", outsearch)
217218
}
218219

219-
listRespStream, err := client.PlatformList(context.Background(), &rpc.PlatformListReq{
220+
listResp, err := client.PlatformList(context.Background(), &rpc.PlatformListReq{
220221
Instance: instance,
221222
})
222223
if err != nil {
223-
fmt.Printf("Search error: %s\n", err)
224+
fmt.Printf("List error: %s\n", err)
224225
os.Exit(1)
225226
}
226-
for {
227-
listResp, err := listRespStream.Recv()
228-
if err == io.EOF {
229-
break
230-
}
231-
if err != nil {
232-
fmt.Printf("Compile error: %s\n", err)
233-
os.Exit(1)
234-
}
235-
if listResp.GetTaskProgress() != nil {
236-
fmt.Printf(">> TASK: %s\n", listResp.GetTaskProgress())
237-
}
238-
if listResp.GetInstalledPlatform() != nil {
239-
Installedplatforms := listResp.GetInstalledPlatform()
240-
for _, listpfm := range Installedplatforms {
241-
fmt.Printf(">> OUTPUT: ID: %s\t Installed Version: %s\t Latest Version: %s\t name: %s\n", listpfm.GetID(), listpfm.GetInstalled(), listpfm.GetLatest(), listpfm.GetName())
242-
}
243-
244-
}
227+
Installedplatforms := listResp.GetInstalledPlatform()
228+
for _, listpfm := range Installedplatforms {
229+
fmt.Printf(">> LIST: %+v\n", listpfm)
245230
}
246231

247232
uninstallRespStream, err := client.PlatformUninstall(context.Background(), &rpc.PlatformUninstallReq{

0 commit comments

Comments
 (0)