Skip to content

Commit ec1310e

Browse files
committed
Removed --no-op from CLI. Preferences now not-saved by default.
See arduino#2000 for details. Close arduino#2000
1 parent e3dc5e7 commit ec1310e

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

app/src/processing/app/Base.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,21 @@ public Base(String[] args) throws Exception {
360360
ACTION action = ACTION.GUI;
361361
boolean doVerboseBuild = false;
362362
boolean doVerboseUpload = false;
363+
boolean forceSavePrefs = false;
363364
String getPref = null;
364365
List<String> filenames = new LinkedList<String>();
365366

366367
// Map of possible actions and corresponding options
367368
final Map<String, ACTION> actions = new HashMap<String, ACTION>();
368369
actions.put("--verify", ACTION.VERIFY);
369370
actions.put("--upload", ACTION.UPLOAD);
370-
actions.put("--noop", ACTION.NOOP);
371371
actions.put("--get-pref", ACTION.GET_PREF);
372372

373373
// Check if any files were passed in on the command line
374374
for (int i = 0; i < args.length; i++) {
375375
ACTION a = actions.get(args[i]);
376376
if (a != null) {
377-
if (action != ACTION.GUI) {
377+
if (action != ACTION.GUI && action != ACTION.NOOP) {
378378
String[] valid = actions.keySet().toArray(new String[0]);
379379
String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
380380
showError(null, mess, 3);
@@ -391,28 +391,38 @@ public Base(String[] args) throws Exception {
391391
if (args[i].equals("--verbose") || args[i].equals("-v")) {
392392
doVerboseBuild = true;
393393
doVerboseUpload = true;
394+
if (action == ACTION.GUI)
395+
action = ACTION.NOOP;
394396
continue;
395397
}
396398
if (args[i].equals("--verbose-build")) {
397399
doVerboseBuild = true;
400+
if (action == ACTION.GUI)
401+
action = ACTION.NOOP;
398402
continue;
399403
}
400404
if (args[i].equals("--verbose-upload")) {
401405
doVerboseUpload = true;
406+
if (action == ACTION.GUI)
407+
action = ACTION.NOOP;
402408
continue;
403409
}
404410
if (args[i].equals("--board")) {
405411
i++;
406412
if (i >= args.length)
407413
showError(null, _("Argument required for --board"), 3);
408414
processBoardArgument(args[i]);
415+
if (action == ACTION.GUI)
416+
action = ACTION.NOOP;
409417
continue;
410418
}
411419
if (args[i].equals("--port")) {
412420
i++;
413421
if (i >= args.length)
414422
showError(null, _("Argument required for --port"), 3);
415423
Base.selectSerialPort(args[i]);
424+
if (action == ACTION.GUI)
425+
action = ACTION.NOOP;
416426
continue;
417427
}
418428
if (args[i].equals("--curdir")) {
@@ -427,10 +437,12 @@ public Base(String[] args) throws Exception {
427437
if (i >= args.length)
428438
showError(null, _("Argument required for --pref"), 3);
429439
processPrefArgument(args[i]);
440+
if (action == ACTION.GUI)
441+
action = ACTION.NOOP;
430442
continue;
431443
}
432-
if (args[i].equals("--no-save-prefs")) {
433-
Preferences.setDoSave(false);
444+
if (args[i].equals("--save-prefs")) {
445+
forceSavePrefs = true;
434446
continue;
435447
}
436448
if (args[i].equals("--preferences-file")) {
@@ -472,6 +484,8 @@ public Base(String[] args) throws Exception {
472484
}
473485

474486
boolean showEditor = (action == ACTION.GUI);
487+
if (!forceSavePrefs)
488+
Preferences.setDoSave(showEditor);
475489
if (handleOpen(file, nextEditorLocation(), showEditor) == null) {
476490
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
477491
// Open failure is fatal in upload/verify mode

build/shared/manpage.adoc

+12-26
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ compiling and uploading sketches (programs) for Arduino
3636
Normally, running the arduino command starts the IDE, optionally loading
3737
any .ino files specified on the commandline.
3838

39-
Alternatively, if *--verify* or *--upload* is given, no graphical
39+
Alternatively, if any of the following command line options is given, no graphical
4040
interface will be shown and instead a one-off verify (compile) or upload
4141
will be done. A single .ino file should be given. If the sketch contains
4242
multiple .ino files, any one can be specified on the commandline, but
@@ -75,9 +75,6 @@ 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 (except when
80-
*--no-save-prefs* is passed).
8178

8279
*--port* __portname__::
8380
Select the serial port to perform upload of the sketch.
@@ -88,13 +85,10 @@ OPTIONS
8885
{empty}::
8986
If this option is not passed, the value from the current
9087
preferences is used (e.g., the last port selected in the IDE).
91-
If this option is given, the value passed is written to the
92-
preferences file and rememberd for subsequent runs (except when
93-
*--no-save-prefs* is passed).
9488

9589
*--verbose-build*::
9690
Enable verbose mode during build. If this option is not given,
97-
verbose mode during build is disabled regardless of the current
91+
verbose mode during build is *disabled* regardless of the current
9892
preferences.
9993

10094
{empty}::
@@ -103,7 +97,7 @@ OPTIONS
10397

10498
*--verbose-upload*::
10599
Enable verbose mode during upload. If this option is not given,
106-
verbose mode during upload is disabled regardless of the current
100+
verbose mode during upload is *disabled* regardless of the current
107101
preferences.
108102

109103
{empty}::
@@ -131,24 +125,17 @@ OPTIONS
131125
validated: Invalid names will be set but never used, invalid
132126
values might lead to an error later on.
133127

134-
{empty}::
135-
If this option is given, the value passed is written to the
136-
preferences file and rememberd for subsequent runs (except when
137-
*--no-save-prefs* is passed).
138-
139-
*--no-save-prefs*::
140-
Do not save any (changed) preferences to *preferences.txt*.
128+
*--save-prefs*::
129+
Save any (changed) preferences to *preferences.txt*. In particular
130+
*--board*, *--port*, *--pref*, *--verbose*, *--verbose-build* and
131+
*--verbose-upload* may alter the current preferences.
141132

142133
*--upload*::
143134
Build and upload the sketch.
144135

145136
*--verify*::
146137
Build the sketch.
147138

148-
*--noop*::
149-
Immediately quit after processing the commandline. This can be
150-
used to just set preferences with *--pref*.
151-
152139
*--get-pref __preference__*::
153140
Prints the value of the given preference to the standard output
154141
stream. When the value does not exist, nothing is printed and
@@ -244,7 +231,7 @@ re-use any previous build results in that directory.
244231

245232
Change the selected board and build path and do nothing else.
246233

247-
arduino --pref build.path=/path/to/sketch/build --board arduino:avr:uno --noop
234+
arduino --pref build.path=/path/to/sketch/build --board arduino:avr:uno --save-prefs
248235

249236
HISTORY
250237
-------
@@ -272,13 +259,12 @@ HISTORY
272259
longer shown. Error messages still use a graphical popup and on
273260
Windows, the splash screen is still shown.
274261
275-
1.5.7::
276-
Introduced *--no-save-prefs* and *--noop*.
262+
1.5.8::
263+
Introduced *--save-prefs*.
277264
278265
{empty}::
279-
*--board* and *--port* options are now saved to the preferences
280-
file, just like *--pref*. The *--verbose* options still only
281-
apply to the current run.
266+
*--pref* options are now not saved to the preferences file, just
267+
like *--board* and *--port*, unless *--save-prefs* is specified.
282268
283269
{empty}::
284270
A path passed to *--preferences-file*, or set in the

0 commit comments

Comments
 (0)