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