Skip to content

Commit 022d550

Browse files
committed
Extended command line flags
1 parent 12ac3f3 commit 022d550

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

app/src/processing/app/Base.java

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ public Base(String[] args) throws Exception {
278278

279279
boolean opened = false;
280280
boolean doUpload = false;
281+
boolean doVerify = false;
282+
boolean doVerbose = false;
281283
String selectBoard = null;
282284
String selectPort = null;
283285
// Check if any files were passed in on the command line
@@ -286,6 +288,14 @@ public Base(String[] args) throws Exception {
286288
doUpload = true;
287289
continue;
288290
}
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+
}
289299
if (args[i].equals("--board")) {
290300
i++;
291301
if (i < args.length)
@@ -316,16 +326,37 @@ public Base(String[] args) throws Exception {
316326
}
317327
}
318328

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+
}
322334
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
323340
Editor editor = editors.get(0);
324-
if (selectPort != null)
325-
editor.selectSerialPort(selectPort);
326341
if (selectBoard != null)
327342
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
329360
System.exit(0);
330361
}
331362

0 commit comments

Comments
 (0)