Unverified Commit 9bc2afcf authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

[breaking] Align `board list --watch` and `board list` json output (#2219)

* Align `board list --watch` and `board list` json output

* Update docs
parent ffb3d2f7
......@@ -4,6 +4,58 @@ Here you can find a list of migration guides to handle breaking changes between
## 0.34.0
### `board list --watch` command JSON output has changed
`board list --watch` command JSON output changed from:
```
{
"type": "add",
"address": "COM3",
"label": "COM3",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"hardwareId": "93B0245008567CB2",
"properties": {
"pid": "0x005E",
"serialNumber": "93B0245008567CB2",
"vid": "0x2341"
},
"boards": [
{
"name": "Arduino Nano RP2040 Connect",
"fqbn": "arduino:mbed_nano:nanorp2040connect"
}
]
}
```
to:
```
{
"eventType": "add",
"matching_boards": [
{
"name": "Arduino Nano RP2040 Connect",
"fqbn": "arduino:mbed_nano:nanorp2040connect"
}
],
"port": {
"address": "COM3",
"label": "COM3",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"properties": {
"pid": "0x005E",
"serialNumber": "93B0245008567CB2",
"vid": "0x2341"
},
"hardware_id": "93B0245008567CB2"
}
}
```
### Updated sketch name specifications
[Sketch name specifications](https://arduino.github.io/arduino-cli/dev/sketch-specification) have been updated to
......
......@@ -99,15 +99,10 @@ func watchList(inst *rpc.Instance) {
for event := range eventsChan {
feedback.PrintResult(watchEvent{
Type: event.EventType,
Label: event.Port.Port.Label,
Address: event.Port.Port.Address,
Protocol: event.Port.Port.Protocol,
ProtocolLabel: event.Port.Port.ProtocolLabel,
HardwareID: event.Port.Port.HardwareId,
Properties: event.Port.Port.Properties,
Boards: event.Port.MatchingBoards,
Error: event.Error,
Type: event.EventType,
Boards: event.Port.MatchingBoards,
Port: event.Port.Port,
Error: event.Error,
})
}
}
......@@ -176,15 +171,10 @@ func (dr result) String() string {
}
type watchEvent struct {
Type string `json:"type"`
Address string `json:"address,omitempty"`
Label string `json:"label,omitempty"`
Protocol string `json:"protocol,omitempty"`
ProtocolLabel string `json:"protocol_label,omitempty"`
HardwareID string `json:"hardwareId,omitempty"`
Properties map[string]string `json:"properties"`
Boards []*rpc.BoardListItem `json:"boards,omitempty"`
Error string `json:"error,omitempty"`
Type string `json:"eventType"`
Boards []*rpc.BoardListItem `json:"matching_boards,omitempty"`
Port *rpc.Port `json:"port,omitempty"`
Error string `json:"error,omitempty"`
}
func (dr watchEvent) Data() interface{} {
......@@ -199,11 +189,11 @@ func (dr watchEvent) String() string {
"remove": tr("Disconnected"),
}[dr.Type]
address := fmt.Sprintf("%s://%s", dr.Protocol, dr.Address)
if dr.Protocol == "serial" || dr.Protocol == "" {
address = dr.Address
address := fmt.Sprintf("%s://%s", dr.Port.Protocol, dr.Port.Address)
if dr.Port.Protocol == "serial" || dr.Port.Protocol == "" {
address = dr.Port.Address
}
protocol := dr.ProtocolLabel
protocol := dr.Port.ProtocolLabel
if boards := dr.Boards; len(boards) > 0 {
sort.Slice(boards, func(i, j int) bool {
x, y := boards[i], boards[j]
......
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