@@ -72,26 +72,32 @@ func runListCommand(cmd *cobra.Command, args []string) {
72
72
}
73
73
74
74
func outputListResp (resp * rpc.BoardListResp ) {
75
- sort .Slice (resp .Ports , func (i , j int ) bool {
76
- x , y := resp .Ports [i ], resp .Ports [j ]
77
- return x .Protocol < y .Protocol || (x .Protocol == y .Protocol && x .Address < y .Address )
75
+ ports := resp .GetPorts ()
76
+ if len (ports ) == 0 {
77
+ formatter .Print ("No boards found." )
78
+ return
79
+ }
80
+ sort .Slice (ports , func (i , j int ) bool {
81
+ x , y := ports [i ], ports [j ]
82
+ return x .GetProtocol () < y .GetProtocol () ||
83
+ (x .GetProtocol () == y .GetProtocol () && x .GetAddress () < y .GetAddress ())
78
84
})
79
85
table := output .NewTable ()
80
86
table .SetHeader ("Port" , "Type" , "Board Name" , "FQBN" )
81
- for _ , port := range resp .Ports {
82
- address := port .Protocol + "://" + port .Address
83
- if port .Protocol == "serial" {
84
- address = port .Address
87
+ for _ , port := range resp .GetPorts () {
88
+ address := port .GetProtocol () + "://" + port .GetAddress ()
89
+ if port .GetProtocol () == "serial" {
90
+ address = port .GetAddress ()
85
91
}
86
- protocol := port .ProtocolLabel
87
- if len ( port .Boards ) > 0 {
88
- sort .Slice (port . Boards , func (i , j int ) bool {
89
- x , y := port . Boards [i ], port . Boards [j ]
90
- return x .Name < y .Name || (x .Name == y .Name && x .FQBN < y .FQBN )
92
+ protocol := port .GetProtocolLabel ()
93
+ if boards := port .GetBoards (); len ( boards ) > 0 {
94
+ sort .Slice (boards , func (i , j int ) bool {
95
+ x , y := boards [i ], boards [j ]
96
+ return x .GetName () < y .GetName () || (x .GetName () == y .GetName () && x .GetFQBN () < y .GetFQBN () )
91
97
})
92
- for _ , b := range port . Boards {
93
- board := b .Name
94
- fqbn := b .FQBN
98
+ for _ , b := range boards {
99
+ board := b .GetName ()
100
+ fqbn := b .GetFQBN ()
95
101
table .AddRow (address , protocol , board , fqbn )
96
102
// show address and protocol only on the first row
97
103
address = ""
0 commit comments