Skip to content

Commit 34f5930

Browse files
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).
1 parent f1a3442 commit 34f5930

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

app/src/processing/app/Base.java

+7-13
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,14 @@ public Base(String[] args) throws Exception {
361361
i++;
362362
if (i >= args.length)
363363
showError(null, _("Argument required for --board"), 3);
364-
selectBoard = args[i];
364+
processBoardArgument(args[i]);
365365
continue;
366366
}
367367
if (args[i].equals("--port")) {
368368
i++;
369369
if (i >= args.length)
370370
showError(null, _("Argument required for --port"), 3);
371-
selectPort = args[i];
371+
Base.selectSerialPort(args[i]);
372372
continue;
373373
}
374374
if (args[i].equals("--curdir")) {
@@ -439,13 +439,8 @@ public Base(String[] args) throws Exception {
439439

440440
Editor editor = editors.get(0);
441441

442-
// Do board selection if requested
443-
processBoardArgument(selectBoard);
444-
445442
if (action == ACTION.UPLOAD) {
446443
// Build and upload
447-
if (selectPort != null)
448-
editor.selectSerialPort(selectPort);
449444
editor.exportHandler.run();
450445
} else {
451446
// Build only
@@ -1456,6 +1451,11 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
14561451
Action action = new AbstractAction(board.getName()) {
14571452
public void actionPerformed(ActionEvent actionevent) {
14581453
selectBoard((TargetBoard)getValue("b"));
1454+
filterVisibilityOfSubsequentBoardMenus((TargetBoard)getValue("b"), 1);
1455+
1456+
onBoardOrPortChange();
1457+
rebuildImportMenu(Editor.importMenu);
1458+
rebuildExamplesMenu(Editor.examplesMenu);
14591459
}
14601460
};
14611461
action.putValue("b", board);
@@ -1592,12 +1592,6 @@ private void selectBoard(TargetBoard targetBoard) {
15921592
File platformFolder = targetPlatform.getFolder();
15931593
Preferences.set("runtime.platform.path", platformFolder.getAbsolutePath());
15941594
Preferences.set("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
1595-
1596-
filterVisibilityOfSubsequentBoardMenus(targetBoard, 1);
1597-
1598-
onBoardOrPortChange();
1599-
rebuildImportMenu(Editor.importMenu);
1600-
rebuildExamplesMenu(Editor.examplesMenu);
16011595
}
16021596

16031597
public static void selectSerialPort(String port) {

build/shared/manpage.adoc

+13-5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ OPTIONS
7575
{empty}::
7676
If this option is not passed, the value from the current
7777
preferences is used (e.g., the last board selected in the IDE).
78+
If this option is given, the value passed is written to the
79+
preferences file and rememberd for subsequent runs.
7880

7981
*--port* __portname__::
8082
Select the serial port to perform upload of the sketch.
@@ -85,6 +87,8 @@ OPTIONS
8587
{empty}::
8688
If this option is not passed, the value from the current
8789
preferences is used (e.g., the last port selected in the IDE).
90+
If this option is given, the value passed is written to the
91+
preferences file and rememberd for subsequent runs.
8892

8993
*--verbose-build*::
9094
Enable verbose mode during build. If this option is not given,
@@ -108,16 +112,15 @@ OPTIONS
108112
*--pref* __name__=__value__::
109113
Sets the preference __name__ to the given __value__.
110114

111-
{empty}::
112-
Currently the preferences set are saved to 'preferences.txt', but
113-
this might change in the future (making them only active during
114-
the current invocation).
115-
116115
{empty}::
117116
Note that the preferences you set with this option are not
118117
validated: Invalid names will be set but never used, invalid
119118
values might lead to an error later on.
120119

120+
{empty}::
121+
If this option is given, the value passed is written to the
122+
preferences file and rememberd for subsequent runs.
123+
121124
*--upload*::
122125
Build and upload the sketch.
123126

@@ -237,6 +240,11 @@ HISTORY
237240
longer shown. Error messages still use a graphical popup and on
238241
Windows, the splash screen is still shown.
239242
243+
1.5.7::
244+
*--board* and *--port* options are now saved to the preferences
245+
file, just like *--pref*. The *--verbose* options still only
246+
apply to the current run.
247+
240248
RESOURCES
241249
---------
242250
Web site: <http://arduino.cc/>

0 commit comments

Comments
 (0)