diff --git a/arduino/cores/board.go b/arduino/cores/board.go index 0512cda86a7..a9ccef20323 100644 --- a/arduino/cores/board.go +++ b/arduino/cores/board.go @@ -54,6 +54,11 @@ func (b *Board) FQBN() string { return platform.Package.Name + ":" + platform.Architecture + ":" + b.BoardID } +// IsHidden returns true if the board is marked as hidden in the platform +func (b *Board) IsHidden() bool { + return b.Properties.GetBoolean("hide") +} + func (b *Board) String() string { return b.FQBN() } diff --git a/cli/board/listall.go b/cli/board/listall.go index 0598b5dc5fd..0de4571b95c 100644 --- a/cli/board/listall.go +++ b/cli/board/listall.go @@ -42,9 +42,12 @@ func initListAllCommand() *cobra.Command { Args: cobra.ArbitraryArgs, Run: runListAllCommand, } + listAllCommand.Flags().BoolVarP(&showHiddenBoard, "show-hidden", "a", false, "Show also boards marked as 'hidden' in the platform") return listAllCommand } +var showHiddenBoard bool + // runListAllCommand list all installed boards func runListAllCommand(cmd *cobra.Command, args []string) { inst, err := instance.CreateInstance() @@ -54,8 +57,9 @@ func runListAllCommand(cmd *cobra.Command, args []string) { } list, err := board.ListAll(context.Background(), &rpc.BoardListAllReq{ - Instance: inst, - SearchArgs: args, + Instance: inst, + SearchArgs: args, + IncludeHiddenBoards: showHiddenBoard, }) if err != nil { feedback.Errorf("Error listing boards: %v", err) @@ -81,9 +85,13 @@ func (dr resultAll) String() string { }) t := table.New() - t.SetHeader("Board Name", "FQBN") + t.SetHeader("Board Name", "FQBN", "") for _, item := range dr.list.GetBoards() { - t.AddRow(item.GetName(), item.GetFQBN()) + hidden := "" + if item.IsHidden { + hidden = "(hidden)" + } + t.AddRow(item.GetName(), item.GetFQBN(), hidden) } return t.Render() } diff --git a/commands/board/listall.go b/commands/board/listall.go index 1a134248be0..082e29fdc88 100644 --- a/commands/board/listall.go +++ b/commands/board/listall.go @@ -56,9 +56,13 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllRe if !match(board.Name()) { continue } + if !req.GetIncludeHiddenBoards() && board.IsHidden() { + continue + } list.Boards = append(list.Boards, &rpc.BoardListItem{ - Name: board.Name(), - FQBN: board.FQBN(), + Name: board.Name(), + FQBN: board.FQBN(), + IsHidden: board.IsHidden(), }) } } diff --git a/rpc/commands/board.pb.go b/rpc/commands/board.pb.go index 8e1692836e6..27a23a395fd 100644 --- a/rpc/commands/board.pb.go +++ b/rpc/commands/board.pb.go @@ -1200,6 +1200,8 @@ type BoardListAllReq struct { Instance *Instance `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` // The search query to filter the board list by. SearchArgs []string `protobuf:"bytes,2,rep,name=search_args,json=searchArgs,proto3" json:"search_args,omitempty"` + // Set to true to get also the boards marked as "hidden" in the platform + IncludeHiddenBoards bool `protobuf:"varint,3,opt,name=include_hidden_boards,json=includeHiddenBoards,proto3" json:"include_hidden_boards,omitempty"` } func (x *BoardListAllReq) Reset() { @@ -1248,6 +1250,13 @@ func (x *BoardListAllReq) GetSearchArgs() []string { return nil } +func (x *BoardListAllReq) GetIncludeHiddenBoards() bool { + if x != nil { + return x.IncludeHiddenBoards + } + return false +} + type BoardListAllResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1305,6 +1314,8 @@ type BoardListItem struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The fully qualified board name. Used to identify the board to a machine. FQBN string `protobuf:"bytes,2,opt,name=FQBN,proto3" json:"FQBN,omitempty"` + // If the board is marked as "hidden" in the platform + IsHidden bool `protobuf:"varint,3,opt,name=is_hidden,json=isHidden,proto3" json:"is_hidden,omitempty"` } func (x *BoardListItem) Reset() { @@ -1353,6 +1364,13 @@ func (x *BoardListItem) GetFQBN() string { return "" } +func (x *BoardListItem) GetIsHidden() bool { + if x != nil { + return x.IsHidden + } + return false +} + var File_commands_board_proto protoreflect.FileDescriptor var file_commands_board_proto_rawDesc = []byte{ @@ -1513,26 +1531,32 @@ var file_commands_board_proto_rawDesc = []byte{ 0x72, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, - 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x71, 0x0a, 0x0f, 0x42, 0x6f, 0x61, - 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x3d, 0x0a, 0x08, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, 0x22, 0x52, 0x0a, 0x10, - 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, - 0x12, 0x3e, 0x0a, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x26, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, - 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, - 0x22, 0x37, 0x0a, 0x0d, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, - 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x46, 0x51, 0x42, 0x4e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x46, 0x51, 0x42, 0x4e, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0xa5, 0x01, 0x0a, 0x0f, 0x42, 0x6f, + 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x3d, 0x0a, + 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, 0x12, 0x32, 0x0a, + 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, + 0x63, 0x6c, 0x75, 0x64, 0x65, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x42, 0x6f, 0x61, 0x72, 0x64, + 0x73, 0x22, 0x52, 0x0a, 0x10, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, + 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3e, 0x0a, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, + 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x54, 0x0a, 0x0d, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, + 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x46, 0x51, + 0x42, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x46, 0x51, 0x42, 0x4e, 0x12, 0x1b, + 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x08, 0x69, 0x73, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x42, 0x2d, 0x5a, 0x2b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, + 0x63, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/rpc/commands/board.proto b/rpc/commands/board.proto index 79afed66ef2..9f2edf736dc 100644 --- a/rpc/commands/board.proto +++ b/rpc/commands/board.proto @@ -197,6 +197,8 @@ message BoardListAllReq { Instance instance = 1; // The search query to filter the board list by. repeated string search_args = 2; + // Set to true to get also the boards marked as "hidden" in the platform + bool include_hidden_boards = 3; } message BoardListAllResp { @@ -209,4 +211,6 @@ message BoardListItem { string name = 1; // The fully qualified board name. Used to identify the board to a machine. string FQBN = 2; + // If the board is marked as "hidden" in the platform + bool is_hidden = 3; } diff --git a/test/test_board.py b/test/test_board.py index b3e04ada9db..bfca50bb5b1 100644 --- a/test/test_board.py +++ b/test/test_board.py @@ -416,6 +416,17 @@ def test_board_details(run_command): # Download samd core pinned to 1.8.6 result = run_command("core install arduino:samd@1.8.6") assert result.ok + + # Test board listall with and without showing hidden elements + result = run_command("board listall MIPS --format json") + assert result.ok + assert result.stdout == "{}" + + result = run_command("board listall MIPS -a --format json") + assert result.ok + result = json.loads(result.stdout) + assert result["boards"][0]["name"] == "Arduino Tian (MIPS Console port)" + result = run_command("board details -b arduino:samd:nano_33_iot --format json") assert result.ok # Sort everything before compare