@@ -11,6 +11,7 @@ import (
11
11
12
12
"github.com/arduino/arduino-create-agent/utilities"
13
13
"github.com/facchinm/go-serial"
14
+ shellwords "github.com/mattn/go-shellwords"
14
15
"github.com/pkg/errors"
15
16
)
16
17
@@ -84,18 +85,18 @@ func Resolve(port, board, file, commandline string, extra Extra, t locater) (str
84
85
}
85
86
86
87
// Do performs a command on a port with a board attached to it
87
- func Do (port , board , file , commandline string , extra Extra , t locater , l logger ) {
88
- debug (l , port , board , file , commandline )
88
+ func Do (port , commandline string , extra Extra , l logger ) error {
89
89
if extra .Network {
90
90
doNetwork ()
91
91
} else {
92
- doSerial (port , board , file , commandline , extra , t , l )
92
+ return doSerial (port , commandline , extra , l )
93
93
}
94
+ return nil
94
95
}
95
96
96
97
func doNetwork () {}
97
98
98
- func doSerial (port , board , file , commandline string , extra Extra , t locater , l logger ) error {
99
+ func doSerial (port , commandline string , extra Extra , l logger ) error {
99
100
// some boards needs to be resetted
100
101
if extra .Use1200bpsTouch {
101
102
var err error
@@ -105,7 +106,12 @@ func doSerial(port, board, file, commandline string, extra Extra, t locater, l l
105
106
}
106
107
}
107
108
108
- return nil
109
+ z , err := shellwords .Parse (commandline )
110
+ if err != nil {
111
+ return errors .Wrapf (err , "Parse commandline" )
112
+ }
113
+
114
+ return program (z [0 ], z [1 :], l )
109
115
}
110
116
111
117
// reset opens the port at 1200bps. It returns the new port name (which could change
@@ -246,7 +252,7 @@ func program(binary string, args []string, l logger) error {
246
252
247
253
go func () {
248
254
for stderrCopy .Scan () {
249
- info (l , stdoutCopy .Text ())
255
+ info (l , stderrCopy .Text ())
250
256
}
251
257
}()
252
258
0 commit comments