Process some commandline arguments earlier

Previously, the --board and --port arguments were stored in a variable
first and only processed later. Now, the arguments are processed right
away.

This does mean that the arguments are processed when the GUI is not yet
initialized, which caused problems with calling onBoardOrPortChange and
friends from selectBoard. However, since the GUI is not initialized,
there is no real reason to call them either - if we just set the
preferences to the right values, the GUI will be initialized correctly
later. For this reason, selectBoard no longer calls the GUI update
methods. Instead, those are called from the GUI code when the board is
changed through the menu instead (e.g., after calling selectBoard).

This commit slightly changes behaviour. Previously, --board and --port
only worked in combination with --verify and --upload, but were ignored
when just starting the IDE. Now, these are processed regardless of the
other options present.

Additionally, this commit causes all changed preferences to be saved.
Previously, only changes with --pref were saved, --board and --port
options were only active for the current run. This was caused because
the saving of the preferences happened as a side effect of loading the
file in the Editor, but only the --pref option was processed at that
time.

Note that the --verbose options are still only active for the current
run and are only valid combined with --verify or --upload (since they
default to non-verbose instead of the current preference).
This commit is contained in:
Matthijs Kooijman 2014-04-07 10:27:39 +02:00 committed by Cristian Maglie
parent 7301b37c7e
commit d3e2208c01
2 changed files with 20 additions and 18 deletions

View File

@ -361,14 +361,14 @@ public class Base {
i++;
if (i >= args.length)
showError(null, _("Argument required for --board"), 3);
selectBoard = args[i];
processBoardArgument(args[i]);
continue;
}
if (args[i].equals("--port")) {
i++;
if (i >= args.length)
showError(null, _("Argument required for --port"), 3);
selectPort = args[i];
Base.selectSerialPort(args[i]);
continue;
}
if (args[i].equals("--curdir")) {
@ -439,13 +439,8 @@ public class Base {
Editor editor = editors.get(0);
// Do board selection if requested
processBoardArgument(selectBoard);
if (action == ACTION.UPLOAD) {
// Build and upload
if (selectPort != null)
editor.selectSerialPort(selectPort);
editor.exportHandler.run();
} else {
// Build only
@ -1456,6 +1451,11 @@ public class Base {
Action action = new AbstractAction(board.getName()) {
public void actionPerformed(ActionEvent actionevent) {
selectBoard((TargetBoard)getValue("b"));
filterVisibilityOfSubsequentBoardMenus((TargetBoard)getValue("b"), 1);
onBoardOrPortChange();
rebuildImportMenu(Editor.importMenu);
rebuildExamplesMenu(Editor.examplesMenu);
}
};
action.putValue("b", board);
@ -1592,12 +1592,6 @@ public class Base {
File platformFolder = targetPlatform.getFolder();
Preferences.set("runtime.platform.path", platformFolder.getAbsolutePath());
Preferences.set("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
filterVisibilityOfSubsequentBoardMenus(targetBoard, 1);
onBoardOrPortChange();
rebuildImportMenu(Editor.importMenu);
rebuildExamplesMenu(Editor.examplesMenu);
}
public static void selectSerialPort(String port) {

View File

@ -75,6 +75,8 @@ OPTIONS
{empty}::
If this option is not passed, the value from the current
preferences is used (e.g., the last board selected in the IDE).
If this option is given, the value passed is written to the
preferences file and rememberd for subsequent runs.
*--port* __portname__::
Select the serial port to perform upload of the sketch.
@ -85,6 +87,8 @@ OPTIONS
{empty}::
If this option is not passed, the value from the current
preferences is used (e.g., the last port selected in the IDE).
If this option is given, the value passed is written to the
preferences file and rememberd for subsequent runs.
*--verbose-build*::
Enable verbose mode during build. If this option is not given,
@ -108,16 +112,15 @@ OPTIONS
*--pref* __name__=__value__::
Sets the preference __name__ to the given __value__.
{empty}::
Currently the preferences set are saved to 'preferences.txt', but
this might change in the future (making them only active during
the current invocation).
{empty}::
Note that the preferences you set with this option are not
validated: Invalid names will be set but never used, invalid
values might lead to an error later on.
{empty}::
If this option is given, the value passed is written to the
preferences file and rememberd for subsequent runs.
*--upload*::
Build and upload the sketch.
@ -237,6 +240,11 @@ HISTORY
longer shown. Error messages still use a graphical popup and on
Windows, the splash screen is still shown.
1.5.7::
*--board* and *--port* options are now saved to the preferences
file, just like *--pref*. The *--verbose* options still only
apply to the current run.
RESOURCES
---------
Web site: <http://arduino.cc/>