@@ -32,6 +32,7 @@ import (
32
32
33
33
"github.com/arduino/arduino-cli/cli/errorcodes"
34
34
"github.com/arduino/arduino-cli/cli/instance"
35
+ "github.com/arduino/arduino-cli/commands/board"
35
36
"github.com/arduino/arduino-cli/commands/compile"
36
37
"github.com/arduino/arduino-cli/commands/upload"
37
38
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
@@ -84,6 +85,9 @@ func NewCommand() *cobra.Command {
84
85
85
86
command .Flags ().StringVarP (& fqbn , "fqbn" , "b" , "" , tr ("Fully Qualified Board Name, e.g.: arduino:avr:uno" ))
86
87
command .MarkFlagRequired ("fqbn" )
88
+ command .RegisterFlagCompletionFunc ("fqbn" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
89
+ return getBoards (toComplete ), cobra .ShellCompDirectiveDefault
90
+ })
87
91
command .Flags ().BoolVar (& showProperties , "show-properties" , false , tr ("Show all build properties used instead of compiling." ))
88
92
command .Flags ().BoolVar (& preprocess , "preprocess" , false , tr ("Print preprocessed code to stdout instead of compiling." ))
89
93
command .Flags ().StringVar (& buildCachePath , "build-cache-path" , "" , tr ("Builds of 'core.a' are saved into this path to be cached and reused." ))
@@ -274,3 +278,19 @@ func (r *compileResult) String() string {
274
278
// The output is already printed via os.Stdout/os.Stdin
275
279
return ""
276
280
}
281
+
282
+ func getBoards (toComplete string ) []string {
283
+ // from listall.go TODO optimize
284
+ inst := instance .CreateAndInit ()
285
+
286
+ list , _ := board .ListAll (context .Background (), & rpc.BoardListAllRequest {
287
+ Instance : inst ,
288
+ SearchArgs : nil ,
289
+ IncludeHiddenBoards : false ,
290
+ })
291
+ var res []string
292
+ for _ , i := range list .GetBoards () {
293
+ res = append (res , i .Fqbn )
294
+ }
295
+ return res
296
+ }
0 commit comments