Skip to content

add fqbn flag for board details command #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cli/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ import (

var tr = i18n.Tr
var showFullDetails bool
var fqbn string

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

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

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

res, err := board.Details(context.Background(), &rpc.BoardDetailsReq{
Instance: inst,
Fqbn: args[0],
Fqbn: fqbn,
})

if err != nil {
Expand Down
27 changes: 26 additions & 1 deletion test/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ 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
result = run_command("board details arduino:samd:nano_33_iot --format json")
result = run_command("board details -b arduino:samd:nano_33_iot --format json")
assert result.ok
# Sort everything before compare
result = json.loads(result.stdout)
Expand All @@ -413,3 +413,28 @@ def test_board_details(run_command):
assert result["platform"] == gold_board_details["platform"]
for usb_id in gold_board_details["identification_pref"]:
assert usb_id in result["identification_pref"]


# old `arduino-cli board details` did not need -b <fqbn> flag to work
def test_board_details_old(run_command):
result = run_command("core update-index")
assert result.ok
# Download samd core pinned to 1.8.6
result = run_command("core install arduino:samd@1.8.6")
assert result.ok
result = run_command("board details arduino:samd:nano_33_iot")
assert not result.ok
assert result.stdout == ""
assert 'Error: unknown command "arduino:samd:nano_33_iot" for "arduino-cli board details"' in result.stderr


def test_board_details_no_flags(run_command):
result = run_command("core update-index")
assert result.ok
# Download samd core pinned to 1.8.6
result = run_command("core install arduino:samd@1.8.6")
assert result.ok
result = run_command("board details")
assert not result.ok
assert 'Error: required flag(s) "fqbn" not set in result.stderr'
assert result.stdout == ""