Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f9f135

Browse files
authored
Added support for hidden boards in 'board listall' command (#939)
* Added support for hidden boards in 'board listall' command * Added test for 'board listall -a'
1 parent 693a045 commit 7f9f135

File tree

6 files changed

+82
-26
lines changed

6 files changed

+82
-26
lines changed

‎arduino/cores/board.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (b *Board) FQBN() string {
5454
return platform.Package.Name + ":" + platform.Architecture + ":" + b.BoardID
5555
}
5656

57+
// IsHidden returns true if the board is marked as hidden in the platform
58+
func (b *Board) IsHidden() bool {
59+
return b.Properties.GetBoolean("hide")
60+
}
61+
5762
func (b *Board) String() string {
5863
return b.FQBN()
5964
}

‎cli/board/listall.go‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ func initListAllCommand() *cobra.Command {
4242
Args: cobra.ArbitraryArgs,
4343
Run: runListAllCommand,
4444
}
45+
listAllCommand.Flags().BoolVarP(&showHiddenBoard, "show-hidden", "a", false, "Show also boards marked as 'hidden' in the platform")
4546
return listAllCommand
4647
}
4748

49+
var showHiddenBoard bool
50+
4851
// runListAllCommand list all installed boards
4952
func runListAllCommand(cmd *cobra.Command, args []string) {
5053
inst, err := instance.CreateInstance()
@@ -54,8 +57,9 @@ func runListAllCommand(cmd *cobra.Command, args []string) {
5457
}
5558

5659
list, err := board.ListAll(context.Background(), &rpc.BoardListAllReq{
57-
Instance: inst,
58-
SearchArgs: args,
60+
Instance: inst,
61+
SearchArgs: args,
62+
IncludeHiddenBoards: showHiddenBoard,
5963
})
6064
if err != nil {
6165
feedback.Errorf("Error listing boards: %v", err)
@@ -81,9 +85,13 @@ func (dr resultAll) String() string {
8185
})
8286

8387
t := table.New()
84-
t.SetHeader("Board Name", "FQBN")
88+
t.SetHeader("Board Name", "FQBN", "")
8589
for _, item := range dr.list.GetBoards() {
86-
t.AddRow(item.GetName(), item.GetFQBN())
90+
hidden := ""
91+
if item.IsHidden {
92+
hidden = "(hidden)"
93+
}
94+
t.AddRow(item.GetName(), item.GetFQBN(), hidden)
8795
}
8896
return t.Render()
8997
}

‎commands/board/listall.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe
5656
if !match(board.Name()) {
5757
continue
5858
}
59+
if !req.GetIncludeHiddenBoards() && board.IsHidden() {
60+
continue
61+
}
5962
list.Boards = append(list.Boards, &rpc.BoardListItem{
60-
Name: board.Name(),
61-
FQBN: board.FQBN(),
63+
Name: board.Name(),
64+
FQBN: board.FQBN(),
65+
IsHidden: board.IsHidden(),
6266
})
6367
}
6468
}

‎rpc/commands/board.pb.go‎

Lines changed: 44 additions & 20 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ message BoardListAllReq {
197197
Instance instance = 1;
198198
// The search query to filter the board list by.
199199
repeated string search_args = 2;
200+
// Set to true to get also the boards marked as "hidden" in the platform
201+
bool include_hidden_boards = 3;
200202
}
201203

202204
message BoardListAllResp {
@@ -209,4 +211,6 @@ message BoardListItem {
209211
string name = 1;
210212
// The fully qualified board name. Used to identify the board to a machine.
211213
string FQBN = 2;
214+
// If the board is marked as "hidden" in the platform
215+
bool is_hidden = 3;
212216
}

‎test/test_board.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ def test_board_details(run_command):
416416
# Download samd core pinned to 1.8.6
417417
result = run_command("core install arduino:samd@1.8.6")
418418
assert result.ok
419+
420+
# Test board listall with and without showing hidden elements
421+
result = run_command("board listall MIPS --format json")
422+
assert result.ok
423+
assert result.stdout == "{}"
424+
425+
result = run_command("board listall MIPS -a --format json")
426+
assert result.ok
427+
result = json.loads(result.stdout)
428+
assert result["boards"][0]["name"] == "Arduino Tian (MIPS Console port)"
429+
419430
result = run_command("board details -b arduino:samd:nano_33_iot --format json")
420431
assert result.ok
421432
# Sort everything before compare

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /