Skip to content

Commit f3f47f0

Browse files
committed
add fqbn flag for board details command
1 parent 82df01f commit f3f47f0

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

cli/board/details.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ import (
3333

3434
var tr = i18n.Tr
3535
var showFullDetails bool
36+
var fqbn string
3637

3738
func initDetailsCommand() *cobra.Command {
3839
var detailsCommand = &cobra.Command{
39-
Use: "details <FQBN>",
40+
Use: "details -b <FQBN>",
4041
Short: tr("Print details about a board."),
4142
Long: tr("Show information about a board, in particular if the board has options to be specified in the FQBN."),
42-
Example: " " + os.Args[0] + " board details arduino:avr:nano",
43-
Args: cobra.ExactArgs(1),
43+
Example: " " + os.Args[0] + " board details -b arduino:avr:nano",
44+
Args: cobra.NoArgs,
4445
Run: runDetailsCommand,
4546
}
4647

4748
detailsCommand.Flags().BoolVarP(&showFullDetails, "full", "f", false, tr("Show full board details"))
49+
detailsCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
50+
detailsCommand.MarkFlagRequired("fqbn")
4851

4952
return detailsCommand
5053
}
@@ -58,7 +61,7 @@ func runDetailsCommand(cmd *cobra.Command, args []string) {
5861

5962
res, err := board.Details(context.Background(), &rpc.BoardDetailsReq{
6063
Instance: inst,
61-
Fqbn: args[0],
64+
Fqbn: fqbn,
6265
})
6366

6467
if err != nil {

test/test_board.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def test_board_details(run_command):
398398
# Download samd core pinned to 1.8.6
399399
result = run_command("core install arduino:samd@1.8.6")
400400
assert result.ok
401-
result = run_command("board details arduino:samd:nano_33_iot --format json")
401+
result = run_command("board details -b arduino:samd:nano_33_iot --format json")
402402
assert result.ok
403403
# Sort everything before compare
404404
result = json.loads(result.stdout)
@@ -413,3 +413,28 @@ def test_board_details(run_command):
413413
assert result["platform"] == gold_board_details["platform"]
414414
for usb_id in gold_board_details["identification_pref"]:
415415
assert usb_id in result["identification_pref"]
416+
417+
418+
# old `arduino-cli board details` did not need -b <fqbn> flag to work
419+
def test_board_details_old(run_command):
420+
result = run_command("core update-index")
421+
assert result.ok
422+
# Download samd core pinned to 1.8.6
423+
result = run_command("core install arduino:samd@1.8.6")
424+
assert result.ok
425+
result = run_command("board details arduino:samd:nano_33_iot")
426+
assert not result.ok
427+
assert result.stdout == ""
428+
assert 'Error: unknown command "arduino:samd:nano_33_iot" for "arduino-cli board details"' in result.stderr
429+
430+
431+
def test_board_details_no_flags(run_command):
432+
result = run_command("core update-index")
433+
assert result.ok
434+
# Download samd core pinned to 1.8.6
435+
result = run_command("core install arduino:samd@1.8.6")
436+
assert result.ok
437+
result = run_command("board details")
438+
assert not result.ok
439+
assert 'Error: required flag(s) "fqbn" not set in result.stderr'
440+
assert result.stdout == ""

0 commit comments

Comments
 (0)