Skip to content

Commit 7a7fa2c

Browse files
committed
added filtering
1 parent 42638df commit 7a7fa2c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cli/device/masscreate.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func initMassCreateCommand() *cobra.Command {
5252
createCommand.Flags().StringVarP(&flags.name, "name", "n", "", "Base device name")
5353
createCommand.Flags().StringVarP(&flags.fqbn, "fqbn", "b", "", "Device fqbn")
5454
createCommand.MarkFlagRequired("name")
55-
createCommand.MarkFlagRequired("fqbn")
5655
return createCommand
5756
}
5857

@@ -68,7 +67,7 @@ func runMassCreateCommand(flags *massCreateFlags) error {
6867
ctx, cancel := cleanup.InterruptableContext(context.Background())
6968
defer cancel()
7069

71-
boards, err := device.ListAllConnectedBoardsWithCrypto()
70+
boards, err := device.ListAllConnectedBoardsWithCrypto(&flags.fqbn)
7271
if err != nil {
7372
return err
7473
}
@@ -86,7 +85,7 @@ func runMassCreateCommand(flags *massCreateFlags) error {
8685
params := &device.CreateParams{
8786
Name: bname,
8887
Port: &board.Address,
89-
FQBN: &flags.fqbn,
88+
FQBN: &board.Fqbn,
9089
}
9190

9291
dev, err := device.Create(ctx, params, cred)

command/device/masscreate.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import (
1010
"go.bug.st/cleanup"
1111
)
1212

13-
func ListAllConnectedBoardsWithCrypto() ([]*Board, error) {
13+
func ListAllConnectedBoardsWithCrypto(fqbn *string) ([]*Board, error) {
1414
comm, err := ListAllConnectedBoards()
1515
if err != nil {
1616
return nil, err
1717
}
1818
var withcrypto []*Board
1919
for _, b := range comm {
20+
if len(*fqbn) > 0 && b.Fqbn != *fqbn {
21+
// Skipp not matching board
22+
continue
23+
}
2024
if b.isCrypto() {
2125
withcrypto = append(withcrypto, b)
2226
}

0 commit comments

Comments
 (0)