|
| 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 | + |
1 | 18 | package main
|
2 | 19 |
|
3 | 20 | import (
|
@@ -187,61 +204,29 @@ func main() {
|
187 | 204 | }
|
188 | 205 | }
|
189 | 206 |
|
190 |
| - searchRespStream, err := client.PlatformSearch(context.Background(), &rpc.PlatformSearchReq{ |
| 207 | + searchResp, err := client.PlatformSearch(context.Background(), &rpc.PlatformSearchReq{ |
191 | 208 | Instance: instance,
|
192 | 209 | SearchArgs: "uno",
|
193 | 210 | })
|
194 | 211 | if err != nil {
|
195 | 212 | fmt.Printf("Search error: %s\n", err)
|
196 | 213 | os.Exit(1)
|
197 | 214 | }
|
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) |
217 | 218 | }
|
218 | 219 |
|
219 |
| - listRespStream, err := client.PlatformList(context.Background(), &rpc.PlatformListReq{ |
| 220 | + listResp, err := client.PlatformList(context.Background(), &rpc.PlatformListReq{ |
220 | 221 | Instance: instance,
|
221 | 222 | })
|
222 | 223 | if err != nil {
|
223 |
| - fmt.Printf("Search error: %s\n", err) |
| 224 | + fmt.Printf("List error: %s\n", err) |
224 | 225 | os.Exit(1)
|
225 | 226 | }
|
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) |
245 | 230 | }
|
246 | 231 |
|
247 | 232 | uninstallRespStream, err := client.PlatformUninstall(context.Background(), &rpc.PlatformUninstallReq{
|
|
0 commit comments