|
25 | 25 | import cc.arduino.Compiler;
|
26 | 26 | import cc.arduino.Constants;
|
27 | 27 | import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
|
| 28 | +import cc.arduino.UploaderUtils; |
28 | 29 | import cc.arduino.contributions.*;
|
29 | 30 | import cc.arduino.contributions.libraries.*;
|
30 | 31 | import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
@@ -377,13 +378,29 @@ public Base(String[] args) throws Exception {
|
377 | 378 | }
|
378 | 379 |
|
379 | 380 | if (parser.isUploadMode()) {
|
380 |
| - splash.splashText(tr("Verifying and uploading...")); |
381 |
| - // XXX: TODO |
382 |
| - //editor.exportHandler.run(); |
383 |
| - // Error during upload |
384 |
| - //if (editor.status.isErr()) { |
385 |
| - // System.exit(1); |
386 |
| - //} |
| 381 | + // Upload |
| 382 | + splash.splashText(tr("Uploading...")); |
| 383 | + |
| 384 | + try { |
| 385 | + List<String> warnings = new ArrayList<>(); |
| 386 | + UploaderUtils uploader = new UploaderUtils(); |
| 387 | + boolean res = uploader.upload(sketch, null, outputFile, |
| 388 | + parser.isDoUseProgrammer(), |
| 389 | + parser.isNoUploadPort(), warnings); |
| 390 | + for (String warning : warnings) { |
| 391 | + System.out.println(tr("Warning") + ": " + warning); |
| 392 | + } |
| 393 | + if (!res) { |
| 394 | + throw new Exception(); |
| 395 | + } |
| 396 | + } catch (Exception e) { |
| 397 | + // Error during upload |
| 398 | + System.out.flush(); |
| 399 | + System.err.flush(); |
| 400 | + System.err |
| 401 | + .println(tr("An error occurred while uploading the sketch")); |
| 402 | + System.exit(1); |
| 403 | + } |
387 | 404 | }
|
388 | 405 |
|
389 | 406 | // No errors exit gracefully
|
|
0 commit comments