1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-21 15:54:39 +01:00

Removed --no-op from CLI. Preferences now not-saved by default.

See https://github.com/arduino/Arduino/pull/2000 for details.

Close #2000
This commit is contained in:
Cristian Maglie 2014-08-22 15:39:33 +02:00
parent e3dc5e75e3
commit ec1310e1bd
2 changed files with 30 additions and 30 deletions

View File

@ -360,6 +360,7 @@ public class Base {
ACTION action = ACTION.GUI; ACTION action = ACTION.GUI;
boolean doVerboseBuild = false; boolean doVerboseBuild = false;
boolean doVerboseUpload = false; boolean doVerboseUpload = false;
boolean forceSavePrefs = false;
String getPref = null; String getPref = null;
List<String> filenames = new LinkedList<String>(); List<String> filenames = new LinkedList<String>();
@ -367,14 +368,13 @@ public class Base {
final Map<String, ACTION> actions = new HashMap<String, ACTION>(); final Map<String, ACTION> actions = new HashMap<String, ACTION>();
actions.put("--verify", ACTION.VERIFY); actions.put("--verify", ACTION.VERIFY);
actions.put("--upload", ACTION.UPLOAD); actions.put("--upload", ACTION.UPLOAD);
actions.put("--noop", ACTION.NOOP);
actions.put("--get-pref", ACTION.GET_PREF); actions.put("--get-pref", ACTION.GET_PREF);
// Check if any files were passed in on the command line // Check if any files were passed in on the command line
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
ACTION a = actions.get(args[i]); ACTION a = actions.get(args[i]);
if (a != null) { if (a != null) {
if (action != ACTION.GUI) { if (action != ACTION.GUI && action != ACTION.NOOP) {
String[] valid = actions.keySet().toArray(new String[0]); String[] valid = actions.keySet().toArray(new String[0]);
String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", ")); String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
showError(null, mess, 3); showError(null, mess, 3);
@ -391,14 +391,20 @@ public class Base {
if (args[i].equals("--verbose") || args[i].equals("-v")) { if (args[i].equals("--verbose") || args[i].equals("-v")) {
doVerboseBuild = true; doVerboseBuild = true;
doVerboseUpload = true; doVerboseUpload = true;
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--verbose-build")) { if (args[i].equals("--verbose-build")) {
doVerboseBuild = true; doVerboseBuild = true;
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--verbose-upload")) { if (args[i].equals("--verbose-upload")) {
doVerboseUpload = true; doVerboseUpload = true;
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--board")) { if (args[i].equals("--board")) {
@ -406,6 +412,8 @@ public class Base {
if (i >= args.length) if (i >= args.length)
showError(null, _("Argument required for --board"), 3); showError(null, _("Argument required for --board"), 3);
processBoardArgument(args[i]); processBoardArgument(args[i]);
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--port")) { if (args[i].equals("--port")) {
@ -413,6 +421,8 @@ public class Base {
if (i >= args.length) if (i >= args.length)
showError(null, _("Argument required for --port"), 3); showError(null, _("Argument required for --port"), 3);
Base.selectSerialPort(args[i]); Base.selectSerialPort(args[i]);
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--curdir")) { if (args[i].equals("--curdir")) {
@ -427,10 +437,12 @@ public class Base {
if (i >= args.length) if (i >= args.length)
showError(null, _("Argument required for --pref"), 3); showError(null, _("Argument required for --pref"), 3);
processPrefArgument(args[i]); processPrefArgument(args[i]);
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue; continue;
} }
if (args[i].equals("--no-save-prefs")) { if (args[i].equals("--save-prefs")) {
Preferences.setDoSave(false); forceSavePrefs = true;
continue; continue;
} }
if (args[i].equals("--preferences-file")) { if (args[i].equals("--preferences-file")) {
@ -472,6 +484,8 @@ public class Base {
} }
boolean showEditor = (action == ACTION.GUI); boolean showEditor = (action == ACTION.GUI);
if (!forceSavePrefs)
Preferences.setDoSave(showEditor);
if (handleOpen(file, nextEditorLocation(), showEditor) == null) { if (handleOpen(file, nextEditorLocation(), showEditor) == null) {
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path); String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
// Open failure is fatal in upload/verify mode // Open failure is fatal in upload/verify mode

View File

@ -36,7 +36,7 @@ compiling and uploading sketches (programs) for Arduino
Normally, running the arduino command starts the IDE, optionally loading Normally, running the arduino command starts the IDE, optionally loading
any .ino files specified on the commandline. any .ino files specified on the commandline.
Alternatively, if *--verify* or *--upload* is given, no graphical Alternatively, if any of the following command line options is given, no graphical
interface will be shown and instead a one-off verify (compile) or upload interface will be shown and instead a one-off verify (compile) or upload
will be done. A single .ino file should be given. If the sketch contains will be done. A single .ino file should be given. If the sketch contains
multiple .ino files, any one can be specified on the commandline, but multiple .ino files, any one can be specified on the commandline, but
@ -75,9 +75,6 @@ OPTIONS
{empty}:: {empty}::
If this option is not passed, the value from the current If this option is not passed, the value from the current
preferences is used (e.g., the last board selected in the IDE). 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 (except when
*--no-save-prefs* is passed).
*--port* __portname__:: *--port* __portname__::
Select the serial port to perform upload of the sketch. Select the serial port to perform upload of the sketch.
@ -88,13 +85,10 @@ OPTIONS
{empty}:: {empty}::
If this option is not passed, the value from the current If this option is not passed, the value from the current
preferences is used (e.g., the last port selected in the IDE). 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 (except when
*--no-save-prefs* is passed).
*--verbose-build*:: *--verbose-build*::
Enable verbose mode during build. If this option is not given, Enable verbose mode during build. If this option is not given,
verbose mode during build is disabled regardless of the current verbose mode during build is *disabled* regardless of the current
preferences. preferences.
{empty}:: {empty}::
@ -103,7 +97,7 @@ OPTIONS
*--verbose-upload*:: *--verbose-upload*::
Enable verbose mode during upload. If this option is not given, Enable verbose mode during upload. If this option is not given,
verbose mode during upload is disabled regardless of the current verbose mode during upload is *disabled* regardless of the current
preferences. preferences.
{empty}:: {empty}::
@ -131,13 +125,10 @@ OPTIONS
validated: Invalid names will be set but never used, invalid validated: Invalid names will be set but never used, invalid
values might lead to an error later on. values might lead to an error later on.
{empty}:: *--save-prefs*::
If this option is given, the value passed is written to the Save any (changed) preferences to *preferences.txt*. In particular
preferences file and rememberd for subsequent runs (except when *--board*, *--port*, *--pref*, *--verbose*, *--verbose-build* and
*--no-save-prefs* is passed). *--verbose-upload* may alter the current preferences.
*--no-save-prefs*::
Do not save any (changed) preferences to *preferences.txt*.
*--upload*:: *--upload*::
Build and upload the sketch. Build and upload the sketch.
@ -145,10 +136,6 @@ OPTIONS
*--verify*:: *--verify*::
Build the sketch. Build the sketch.
*--noop*::
Immediately quit after processing the commandline. This can be
used to just set preferences with *--pref*.
*--get-pref __preference__*:: *--get-pref __preference__*::
Prints the value of the given preference to the standard output Prints the value of the given preference to the standard output
stream. When the value does not exist, nothing is printed and stream. When the value does not exist, nothing is printed and
@ -244,7 +231,7 @@ re-use any previous build results in that directory.
Change the selected board and build path and do nothing else. Change the selected board and build path and do nothing else.
arduino --pref build.path=/path/to/sketch/build --board arduino:avr:uno --noop arduino --pref build.path=/path/to/sketch/build --board arduino:avr:uno --save-prefs
HISTORY HISTORY
------- -------
@ -272,13 +259,12 @@ HISTORY
longer shown. Error messages still use a graphical popup and on longer shown. Error messages still use a graphical popup and on
Windows, the splash screen is still shown. Windows, the splash screen is still shown.
1.5.7:: 1.5.8::
Introduced *--no-save-prefs* and *--noop*. Introduced *--save-prefs*.
{empty}:: {empty}::
*--board* and *--port* options are now saved to the preferences *--pref* options are now not saved to the preferences file, just
file, just like *--pref*. The *--verbose* options still only like *--board* and *--port*, unless *--save-prefs* is specified.
apply to the current run.
{empty}:: {empty}::
A path passed to *--preferences-file*, or set in the A path passed to *--preferences-file*, or set in the