1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Improve commandline handling control flow

This uses a switch on the action value, which makes it more clear what
code runs when. No actual behaviour is changed, most of the changes in
this commit are indentation changes.
This commit is contained in:
Matthijs Kooijman
2014-04-07 10:06:48 +02:00
committed by Cristian Maglie
parent f3565a1bda
commit 7548591d51

View File

@ -430,46 +430,50 @@ public class Base {
} }
} }
if (action == ACTION.UPLOAD || action == ACTION.VERIFY) { switch (action) {
// Set verbosity for command line build case VERIFY:
Preferences.set("build.verbose", "" + doVerboseBuild); case UPLOAD:
Preferences.set("upload.verbose", "" + doVerboseUpload); // Set verbosity for command line build
Preferences.set("build.verbose", "" + doVerboseBuild);
Preferences.set("upload.verbose", "" + doVerboseUpload);
Editor editor = editors.get(0); Editor editor = editors.get(0);
// Do board selection if requested // Do board selection if requested
processBoardArgument(selectBoard); processBoardArgument(selectBoard);
if (action == ACTION.UPLOAD) {
// Build and upload
if (selectPort != null)
editor.selectSerialPort(selectPort);
editor.exportHandler.run();
} else {
// Build only
editor.runHandler.run();
}
// Error during build or upload if (action == ACTION.UPLOAD) {
int res = editor.status.mode; // Build and upload
if (res == EditorStatus.ERR) if (selectPort != null)
System.exit(1); editor.selectSerialPort(selectPort);
editor.exportHandler.run();
} else {
// Build only
editor.runHandler.run();
}
// No errors exit gracefully // Error during build or upload
System.exit(0); int res = editor.status.mode;
} if (res == EditorStatus.ERR)
System.exit(1);
// Check if there were previously opened sketches to be restored // No errors exit gracefully
restoreSketches(); System.exit(0);
break;
case GUI:
// Check if there were previously opened sketches to be restored
restoreSketches();
// Create a new empty window (will be replaced with any files to be opened) // Create a new empty window (will be replaced with any files to be opened)
if (editors.isEmpty()) { if (editors.isEmpty()) {
handleNew(); handleNew();
} }
// Check for updates // Check for updates
if (Preferences.getBoolean("update.check")) { if (Preferences.getBoolean("update.check")) {
new UpdateCheck(this); new UpdateCheck(this);
}
break;
} }
} }