@@ -278,6 +278,8 @@ public Base(String[] args) throws Exception {
278
278
279
279
boolean opened = false ;
280
280
boolean doUpload = false ;
281
+ boolean doVerify = false ;
282
+ boolean doVerbose = false ;
281
283
String selectBoard = null ;
282
284
String selectPort = null ;
283
285
// Check if any files were passed in on the command line
@@ -286,6 +288,14 @@ public Base(String[] args) throws Exception {
286
288
doUpload = true ;
287
289
continue ;
288
290
}
291
+ if (args [i ].equals ("--verify" )) {
292
+ doVerify = true ;
293
+ continue ;
294
+ }
295
+ if (args [i ].equals ("--verbose" ) || args [i ].equals ("-v" )) {
296
+ doVerbose = true ;
297
+ continue ;
298
+ }
289
299
if (args [i ].equals ("--board" )) {
290
300
i ++;
291
301
if (i < args .length )
@@ -316,16 +326,37 @@ public Base(String[] args) throws Exception {
316
326
}
317
327
}
318
328
319
- if (doUpload ) {
320
- if (!opened )
321
- throw new Exception (_ ("Can't open source sketch!" ));
329
+ if (doUpload || doVerify ) {
330
+ if (!opened ) {
331
+ System .out .println (_ ("Can't open source sketch!" ));
332
+ System .exit (2 );
333
+ }
322
334
Thread .sleep (2000 );
335
+ // Set verbosity for command line build
336
+ Preferences .set ("build.verbose" , "" + doVerbose );
337
+ Preferences .set ("upload.verbose" , "" + doVerbose );
338
+
339
+ // Do board selection if requested
323
340
Editor editor = editors .get (0 );
324
- if (selectPort != null )
325
- editor .selectSerialPort (selectPort );
326
341
if (selectBoard != null )
327
342
selectBoard (selectBoard , editor );
328
- editor .exportHandler .run ();
343
+
344
+ if (doUpload ) {
345
+ // Build and upload
346
+ if (selectPort != null )
347
+ editor .selectSerialPort (selectPort );
348
+ editor .exportHandler .run ();
349
+ } else {
350
+ // Build only
351
+ editor .runHandler .run ();
352
+ }
353
+
354
+ // Error during build or upload
355
+ int res = editor .status .mode ;
356
+ if (res == EditorStatus .ERR )
357
+ System .exit (1 );
358
+
359
+ // No errors exit gracefully
329
360
System .exit (0 );
330
361
}
331
362
0 commit comments