Skip to content

Commit 5ba319d

Browse files
committed
now 'board listall' command accept search params
1 parent 98fec8b commit 5ba319d

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,13 @@ arduino:samd 1.6.19 Arduino SAMD Boards (32-bits ARM Cortex-M0+)
306306

307307
once the core is determined you should install it with `arduino-cli core install arduino:samd` and, once installed, you can connect the board and detect it with `arduino-cli board list`.
308308

309-
If the board is not detected for any reason, you can list all the supported boards with `arduino-cli board listall`
309+
If the board is not detected for any reason, you can list all the supported boards with `arduino-cli board listall` and also search for a specific board, in our example `arduino-cli board listall zero`.
310+
311+
```
312+
$ arduino-cli board listall zero
313+
Board Name FQBN
314+
Arduino MKRZERO arduino:samd:mkrzero
315+
Arduino/Genuino Zero (Native USB Port) arduino:samd:arduino_zero_native
316+
Arduino/Genuino Zero (Programming Port) arduino:samd:arduino_zero_edbg
317+
```
318+

commands/board/listall.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package board
1919

2020
import (
2121
"sort"
22+
"strings"
2223

2324
"github.com/arduino/arduino-cli/commands"
2425
"github.com/arduino/arduino-cli/common/formatter"
@@ -28,12 +29,16 @@ import (
2829

2930
func initListAllCommand() *cobra.Command {
3031
listAllCommand := &cobra.Command{
31-
Use: "listall",
32-
Short: "List all known boards.",
33-
Long: "List all boards that have the support platform installed.",
34-
Example: " " + commands.AppName + " board listall",
35-
Args: cobra.NoArgs,
36-
Run: runListAllCommand,
32+
Use: "listall [boardname]",
33+
Short: "List all known boards and their corresponding FQBN.",
34+
Long: "" +
35+
"List all boards that have the support platform installed. You can search\n" +
36+
"for a specific board if you specify the board name",
37+
Example: "" +
38+
" " + commands.AppName + " board listall\n" +
39+
" " + commands.AppName + " board listall zero",
40+
Args: cobra.ArbitraryArgs,
41+
Run: runListAllCommand,
3742
}
3843
return listAllCommand
3944
}
@@ -42,6 +47,16 @@ func initListAllCommand() *cobra.Command {
4247
func runListAllCommand(cmd *cobra.Command, args []string) {
4348
pm := commands.InitPackageManager()
4449

50+
match := func(name string) bool {
51+
name = strings.ToLower(name)
52+
for _, term := range args {
53+
if !strings.Contains(name, strings.ToLower(term)) {
54+
return false
55+
}
56+
}
57+
return true
58+
}
59+
4560
list := &output.BoardList{}
4661
for _, targetPackage := range pm.GetPackages().Packages {
4762
for _, platform := range targetPackage.Platforms {
@@ -50,6 +65,9 @@ func runListAllCommand(cmd *cobra.Command, args []string) {
5065
continue
5166
}
5267
for _, board := range platformRelease.Boards {
68+
if !match(board.Name()) {
69+
continue
70+
}
5371
list.Boards = append(list.Boards, &output.BoardListItem{
5472
Name: board.Name(),
5573
Fqbn: board.FQBN(),

0 commit comments

Comments
 (0)