@@ -31,6 +31,7 @@ import (
3131
3232 "github.com/arduino/arduino-cli/cli/errorcodes"
3333 "github.com/arduino/arduino-cli/cli/instance"
34+ "github.com/arduino/arduino-cli/commands/board"
3435 "github.com/arduino/arduino-cli/commands/compile"
3536 "github.com/arduino/arduino-cli/commands/upload"
3637 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
@@ -83,6 +84,9 @@ func NewCommand() *cobra.Command {
8384
8485 command .Flags ().StringVarP (& fqbn , "fqbn" , "b" , "" , tr ("Fully Qualified Board Name, e.g.: arduino:avr:uno" ))
8586 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+ })
8690 command .Flags ().BoolVar (& showProperties , "show-properties" , false , tr ("Show all build properties used instead of compiling." ))
8791 command .Flags ().BoolVar (& preprocess , "preprocess" , false , tr ("Print preprocessed code to stdout instead of compiling." ))
8892 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 {
273277 // The output is already printed via os.Stdout/os.Stdin
274278 return ""
275279}
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