@@ -30,6 +30,8 @@ import (
3030 "github.com/spf13/cobra"
3131)
3232
33+ var searchTimeout string // Expressed in a parsable duration, is the timeout for the list and attach commands.
34+
3335func initAttachCommand () * cobra.Command {
3436 attachCommand := & cobra.Command {
3537 Use : fmt .Sprintf ("attach <%s>|<%s> [%s]" , tr ("port" ), tr ("FQBN" ), tr ("sketchPath" )),
@@ -41,15 +43,11 @@ func initAttachCommand() *cobra.Command {
4143 Args : cobra .RangeArgs (1 , 2 ),
4244 Run : runAttachCommand ,
4345 }
44- attachCommand .Flags ().StringVar (& attachFlags . searchTimeout , "timeout" , "5s" ,
46+ attachCommand .Flags ().StringVar (& searchTimeout , "timeout" , "5s" ,
4547 tr ("The connected devices search timeout, raise it if your board doesn't show up (e.g. to %s)." , "10s" ))
4648 return attachCommand
4749}
4850
49- var attachFlags struct {
50- searchTimeout string // Expressed in a parsable duration, is the timeout for the list and attach commands.
51- }
52-
5351func runAttachCommand (cmd * cobra.Command , args []string ) {
5452 instance := instance .CreateAndInit ()
5553
@@ -63,7 +61,7 @@ func runAttachCommand(cmd *cobra.Command, args []string) {
6361 Instance : instance ,
6462 BoardUri : args [0 ],
6563 SketchPath : sketchPath .String (),
66- SearchTimeout : attachFlags . searchTimeout ,
64+ SearchTimeout : searchTimeout ,
6765 }, output .TaskProgress ()); err != nil {
6866 feedback .Errorf (tr ("Attach board error: %v" ), err )
6967 os .Exit (errorcodes .ErrGeneric )
0 commit comments