Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6303ba3

Browse files
authored
add flag to allow board options to be specified seperately from fqbn (#1688)
1 parent c918d8b commit 6303ba3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎cli/arguments/fqbn.go‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515

1616
package arguments
1717

18-
import "github.com/spf13/cobra"
18+
import (
19+
"strings"
20+
21+
"github.com/spf13/cobra"
22+
)
1923

2024
// Fqbn contains the fqbn flag data.
2125
// This is useful so all flags used by commands that need
2226
// this information are consistent with each other.
2327
type Fqbn struct {
24-
fqbn string
28+
fqbn string
29+
boardOptions []string // List of boards specific options separated by commas. Or can be used multiple times for multiple options.
2530
}
2631

2732
// AddToCommand adds the flags used to set fqbn to the specified Command
@@ -30,10 +35,18 @@ func (f *Fqbn) AddToCommand(cmd *cobra.Command) {
3035
cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
3136
return GetInstalledBoards(), cobra.ShellCompDirectiveDefault
3237
})
38+
cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{},
39+
tr("List of board options separated by commas. Or can be used multiple times for multiple options."))
3340
}
3441

35-
// String returns the fqbn
42+
// String returns the fqbn with the board options if there are any
3643
func (f *Fqbn) String() string {
44+
// If boardOptions are passed with the "--board-options" flags then add them along with the fqbn
45+
// This way it's possible to use either the legacy way (appending board options directly to the fqbn),
46+
// or the new and more elegant way (using "--board-options"), even using multiple "--board-options" works.
47+
if f.fqbn != "" && len(f.boardOptions) != 0 {
48+
return f.fqbn + ":" + strings.Join(f.boardOptions, ",")
49+
}
3750
return f.fqbn
3851
}
3952

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /