Skip to content

Commit f1a6481

Browse files
committed
Add board's platform to board listall json output
1 parent b2b9fba commit f1a6481

File tree

8 files changed

+413
-353
lines changed

8 files changed

+413
-353
lines changed

commands/board/listall.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,31 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
4848
list := &rpc.BoardListAllResp{Boards: []*rpc.BoardListItem{}}
4949
for _, targetPackage := range pm.Packages {
5050
for _, platform := range targetPackage.Platforms {
51-
platformRelease := pm.GetInstalledPlatformRelease(platform)
52-
if platformRelease == nil {
51+
installedPlatformRelease := pm.GetInstalledPlatformRelease(platform)
52+
// We only want to list boards for installed platforms
53+
if installedPlatformRelease == nil {
5354
continue
5455
}
55-
for _, board := range platformRelease.Boards {
56+
57+
installedVersion := installedPlatformRelease.Version.String()
58+
59+
latestVersion := ""
60+
if latestPlatformRelease := platform.GetLatestRelease(); latestPlatformRelease != nil {
61+
latestVersion = latestPlatformRelease.Version.String()
62+
}
63+
64+
rpcPlatform := &rpc.Platform{
65+
ID: platform.String(),
66+
Installed: installedVersion,
67+
Latest: latestVersion,
68+
Name: platform.Name,
69+
Maintainer: platform.Package.Maintainer,
70+
Website: platform.Package.WebsiteURL,
71+
Email: platform.Package.Email,
72+
ManuallyInstalled: platform.ManuallyInstalled,
73+
}
74+
75+
for _, board := range installedPlatformRelease.Boards {
5676
if !match(board.Name()) {
5777
continue
5878
}
@@ -63,6 +83,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
6383
Name: board.Name(),
6484
FQBN: board.FQBN(),
6585
IsHidden: board.IsHidden(),
86+
Platform: rpcPlatform,
6687
})
6788
}
6889
}

rpc/commands/board.pb.go

Lines changed: 28 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/commands/board.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,6 @@ message BoardListItem {
235235
string VID = 4;
236236
// Product ID
237237
string PID = 5;
238+
// Platform this board belongs to
239+
Platform platform = 6;
238240
}

0 commit comments

Comments
 (0)