@@ -44,34 +44,43 @@ var arduinoBoardAttachCmd = &cobra.Command{
4444// executeBoardListCommand detects and lists the connected arduino boards
4545// (either via serial or network ports).
4646func executeBoardListCommand (cmd * cobra.Command , args []string ) {
47+ if len (args ) > 0 {
48+ formatter .PrintErrorMessage ("Not accepting additional arguments" )
49+ os .Exit (errBadCall )
50+ }
4751 monitor := discovery .New (time .Millisecond )
4852 monitor .Start ()
4953 duration , err := time .ParseDuration (arduinoBoardListFlags .SearchTimeout )
5054 if err != nil {
5155 duration = time .Second * 5
5256 }
53- stoppable := cc .Run (func (stop chan struct {}) {
54- for {
55- select {
56- case <- stop :
57- fmt .Print ("\r " )
58- return
59- default :
60- fmt .Print ("\r Discovering. " )
61- time .Sleep (time .Millisecond * 500 )
62- fmt .Print ("\r Discovering.. " )
63- time .Sleep (time .Millisecond * 500 )
64- fmt .Print ("\r Discovering..." )
65- time .Sleep (time .Millisecond * 500 )
57+ if formatter .IsCurrentFormat ("text" ) {
58+ stoppable := cc .Run (func (stop chan struct {}) {
59+ for {
60+ select {
61+ case <- stop :
62+ fmt .Print ("\r " )
63+ return
64+ default :
65+ fmt .Print ("\r Discovering. " )
66+ time .Sleep (time .Millisecond * 500 )
67+ fmt .Print ("\r Discovering.. " )
68+ time .Sleep (time .Millisecond * 500 )
69+ fmt .Print ("\r Discovering..." )
70+ time .Sleep (time .Millisecond * 500 )
71+ }
72+
6673 }
74+ })
6775
68- }
69- })
76+ fmt .Print ("\r " )
7077
71- time .Sleep (duration )
72- stoppable .Stop ()
73- <- stoppable .Stopped
74- fmt .Print ("\r " )
78+ time .Sleep (duration )
79+ stoppable .Stop ()
80+ <- stoppable .Stopped
81+ } else {
82+ time .Sleep (duration )
83+ }
7584 formatter .Print (* monitor )
7685 //monitor.Stop() //If called will slow like 1sec the program to close after print, with the same result (tested).
7786 // it closes ungracefully, but at the end of the command we can't have races.
0 commit comments