Skip to content

Commit 7e15fd1

Browse files
committed
Board details now shows pluggable discovery identification props
1 parent d011848 commit 7e15fd1

File tree

10 files changed

+413
-470
lines changed

10 files changed

+413
-470
lines changed

cli/board/details.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ func (dr detailsResult) String() string {
130130
table.NewCell("✔", color.New(color.FgGreen)))
131131
}
132132

133-
for i, idp := range details.IdentificationPrefs {
134-
if i == 0 {
135-
t.AddRow() // get some space from above
136-
t.AddRow(tr("Identification properties:"), "VID:"+idp.UsbId.Vid+" PID:"+idp.UsbId.Pid)
137-
continue
133+
for _, idp := range details.GetIdentificationProperties() {
134+
t.AddRow() // get some space from above
135+
header := tr("Identification properties:")
136+
for k, v := range idp.GetProperties() {
137+
t.AddRow(header, k+"="+v)
138+
header = ""
138139
}
139-
t.AddRow("", "VID:"+idp.UsbId.Vid+" PID:"+idp.UsbId.Pid)
140140
}
141141

142142
t.AddRow() // get some space from above
@@ -159,14 +159,14 @@ func (dr detailsResult) String() string {
159159

160160
t.AddRow() // get some space from above
161161
for _, tool := range details.ToolsDependencies {
162-
t.AddRow(tr("Required tool:"), tool.Packager+":"+tool.Name, "", tool.Version)
162+
t.AddRow(tr("Required tool:"), tool.Packager+":"+tool.Name, tool.Version)
163163
if showFullDetails {
164164
for _, sys := range tool.Systems {
165-
t.AddRow("", tr("OS:"), "", sys.Host)
166-
t.AddRow("", tr("File:"), "", sys.ArchiveFilename)
167-
t.AddRow("", tr("Size (bytes):"), "", fmt.Sprint(sys.Size))
168-
t.AddRow("", tr("Checksum:"), "", sys.Checksum)
169-
t.AddRow("", "URL:", "", sys.Url)
165+
t.AddRow("", tr("OS:"), sys.Host)
166+
t.AddRow("", tr("File:"), sys.ArchiveFilename)
167+
t.AddRow("", tr("Size (bytes):"), fmt.Sprint(sys.Size))
168+
t.AddRow("", tr("Checksum:"), sys.Checksum)
169+
t.AddRow("", "URL:", sys.Url)
170170
t.AddRow() // get some space from above
171171
}
172172
}

commands/board/details.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
5050
details.PropertiesId = board.BoardID
5151
details.Official = fqbn.Package == "arduino"
5252
details.Version = board.PlatformRelease.Version.String()
53+
details.IdentificationProperties = []*rpc.BoardIdentificationProperties{}
54+
for _, p := range board.GetIdentificationProperties() {
55+
details.IdentificationProperties = append(details.IdentificationProperties, &rpc.BoardIdentificationProperties{
56+
Properties: p.AsMap(),
57+
})
58+
}
5359

5460
details.DebuggingSupported = boardProperties.ContainsKey("debug.executable") ||
5561
boardPlatform.Properties.ContainsKey("debug.executable") ||
@@ -80,16 +86,6 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
8086
details.Platform.Size = boardPlatform.Resource.Size
8187
}
8288

83-
details.IdentificationPrefs = []*rpc.IdentificationPref{}
84-
vids := board.Properties.SubTree("vid")
85-
pids := board.Properties.SubTree("pid")
86-
for id, vid := range vids.AsMap() {
87-
if pid, ok := pids.GetOk(id); ok {
88-
idPref := rpc.IdentificationPref{UsbId: &rpc.USBID{Vid: vid, Pid: pid}}
89-
details.IdentificationPrefs = append(details.IdentificationPrefs, &idPref)
90-
}
91-
}
92-
9389
details.ConfigOptions = []*rpc.ConfigOption{}
9490
options := board.GetConfigOptions()
9591
for _, option := range options.Keys() {

0 commit comments

Comments
 (0)