@@ -190,26 +190,37 @@ func checkCmd(m []byte) {
190
190
go spList (false )
191
191
go spList (true )
192
192
} else if strings .HasPrefix (sl , "downloadtool" ) {
193
- args := strings .Split (s , " " )
194
- if len (args ) > 1 {
195
- go func () {
196
- var err error
197
- if args [1 ] == "avrdude" {
198
- err = Tools .Download (args [1 ], "6.0.1-arduino5" , "keep" )
199
- } else {
200
- err = Tools .Download (args [1 ], "latest" , "keep" )
201
- }
202
- if err != nil {
203
- mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
204
- mapB , _ := json .Marshal (mapD )
205
- h .broadcastSys <- mapB
206
- } else {
207
- mapD := map [string ]string {"DownloadStatus" : "Success" , "Msg" : "Map Updated" }
208
- mapB , _ := json .Marshal (mapD )
209
- h .broadcastSys <- mapB
210
- }
211
- }()
212
- }
193
+ go func () {
194
+ args := strings .Split (s , " " )
195
+ var tool , toolVersion , behaviour string
196
+ toolVersion = "latest"
197
+ behaviour = "keep"
198
+ if len (args ) < 1 {
199
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : "Not enough arguments" }
200
+ mapB , _ := json .Marshal (mapD )
201
+ h .broadcastSys <- mapB
202
+ }
203
+ if len (args ) > 1 {
204
+ tool = args [1 ]
205
+ }
206
+ if len (args ) > 2 {
207
+ toolVersion = args [2 ]
208
+ }
209
+ if len (args ) > 3 {
210
+ behaviour = args [3 ]
211
+ }
212
+
213
+ err := Tools .Download (tool , toolVersion , behaviour )
214
+ if err != nil {
215
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
216
+ mapB , _ := json .Marshal (mapD )
217
+ h .broadcastSys <- mapB
218
+ } else {
219
+ mapD := map [string ]string {"DownloadStatus" : "Success" , "Msg" : "Map Updated" }
220
+ mapB , _ := json .Marshal (mapD )
221
+ h .broadcastSys <- mapB
222
+ }
223
+ }()
213
224
} else if strings .HasPrefix (sl , "bufferalgorithm" ) {
214
225
go spBufferAlgorithms ()
215
226
} else if strings .HasPrefix (sl , "log" ) {
0 commit comments