Skip to content
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
Prev Previous commit
Next Next commit
refactor: style
  • Loading branch information
Luca Bianconi committed Jan 27, 2023
commit 29a96664f323d02adf1db11a819ada15dcc227a2
6 changes: 3 additions & 3 deletions internal/cli/arguments/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ type Fqbn struct {

// AddToCommand adds the flags used to set fqbn and the board options to the specified Command
func (f *Fqbn) AddToCommand(cmd *cobra.Command) {
f.addToCommand(cmd, true)
f.configureForCommand(cmd, true)
}

// AddToCommandWithoutBoardOptions adds the flags used to set fqbn to the specified Command, board options flag is not provided
func (f *Fqbn) AddToCommandWithoutBoardOptions(cmd *cobra.Command) {
f.addToCommand(cmd, false)
f.configureForCommand(cmd, false)
}

func (f *Fqbn) addToCommand(cmd *cobra.Command, enableBoardOptions bool) bool {
func (f *Fqbn) configureForCommand(cmd *cobra.Command, enableBoardOptions bool) bool {
cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return GetInstalledBoards(), cobra.ShellCompDirectiveDefault
Expand Down
12 changes: 7 additions & 5 deletions internal/cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package board

import (
"errors"
"fmt"
"os"
"sort"
Expand Down Expand Up @@ -65,18 +66,19 @@ func runListCommand(cmd *cobra.Command, args []string) {
return
}

ports, discvoeryErrors, err := board.List(&rpc.BoardListRequest{
ports, discoveryErrors, err := board.List(&rpc.BoardListRequest{
Instance: inst,
Timeout: timeoutArg.Get().Milliseconds(),
Fqbn: fqbn.String(),
})
var invalidFQBNErr *arduino.InvalidFQBNError
if errors.As(err, &invalidFQBNErr) {
feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument)
}
if err != nil {
if _, isFqbnError := err.(*arduino.InvalidFQBNError); isFqbnError {
feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument)
}
feedback.Warning(tr("Error detecting boards: %v", err))
}
for _, err := range discvoeryErrors {
for _, err := range discoveryErrors {
feedback.Warning(tr("Error starting discovery: %v", err))
}
feedback.PrintResult(result{ports})
Expand Down