Skip to content

Commit 74441de

Browse files
author
Luca Bianconi
committed
refactor: style
1 parent 076dfce commit 74441de

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Diff for: internal/cli/arguments/fqbn.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ type Fqbn struct {
3535

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

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

46-
func (f *Fqbn) addToCommand(cmd *cobra.Command, enableBoardOptions bool) bool {
46+
func (f *Fqbn) configureForCommand(cmd *cobra.Command, enableBoardOptions bool) bool {
4747
cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
4848
cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
4949
return GetInstalledBoards(), cobra.ShellCompDirectiveDefault

Diff for: internal/cli/board/list.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package board
1717

1818
import (
19+
"errors"
1920
"fmt"
2021
"os"
2122
"sort"
@@ -65,18 +66,19 @@ func runListCommand(cmd *cobra.Command, args []string) {
6566
return
6667
}
6768

68-
ports, discvoeryErrors, err := board.List(&rpc.BoardListRequest{
69+
ports, discoveryErrors, err := board.List(&rpc.BoardListRequest{
6970
Instance: inst,
7071
Timeout: timeoutArg.Get().Milliseconds(),
7172
Fqbn: fqbn.String(),
7273
})
74+
var invalidFQBNErr *arduino.InvalidFQBNError
75+
if errors.As(err, &invalidFQBNErr) {
76+
feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument)
77+
}
7378
if err != nil {
74-
if _, isFqbnError := err.(*arduino.InvalidFQBNError); isFqbnError {
75-
feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument)
76-
}
7779
feedback.Warning(tr("Error detecting boards: %v", err))
7880
}
79-
for _, err := range discvoeryErrors {
81+
for _, err := range discoveryErrors {
8082
feedback.Warning(tr("Error starting discovery: %v", err))
8183
}
8284
feedback.PrintResult(result{ports})

0 commit comments

Comments
 (0)