Add --no-save-prefs option

This allows setting preferences for the current run only, without
remembering them for the next run. This is especially useful when
combined with --verify or --upload.
This commit is contained in:
Matthijs Kooijman 2014-04-07 10:40:45 +02:00 committed by Cristian Maglie
parent bbd0128664
commit 4452eb3850
3 changed files with 24 additions and 3 deletions

View File

@ -385,6 +385,10 @@ public class Base {
processPrefArgument(args[i]);
continue;
}
if (args[i].equals("--no-save-prefs")) {
Preferences.setDoSave(false);
continue;
}
if (args[i].equals("--preferences-file")) {
i++;
if (i >= args.length)

View File

@ -220,6 +220,7 @@ public class Preferences {
static Hashtable<String, String> defaults;
static Hashtable<String, String> table = new Hashtable<String, String>();
static File preferencesFile;
static boolean doSave = true;
static protected void init(String args[]) {
@ -789,6 +790,7 @@ public class Preferences {
static protected void save() {
if (!doSave) return;
// try {
// on startup, don't worry about it
// this is trying to update the prefs for who is open
@ -989,4 +991,10 @@ public class Preferences {
return new PreferencesMap(table);
}
// Decide wether changed preferences will be saved. When value is
// false, Preferences.save becomes a no-op.
static public void setDoSave(boolean value)
{
doSave = value;
}
}

View File

@ -76,7 +76,8 @@ OPTIONS
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.
preferences file and rememberd for subsequent runs (except when
*--no-save-prefs* is passed).
*--port* __portname__::
Select the serial port to perform upload of the sketch.
@ -88,7 +89,8 @@ OPTIONS
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.
preferences file and rememberd for subsequent runs (except when
*--no-save-prefs* is passed).
*--verbose-build*::
Enable verbose mode during build. If this option is not given,
@ -131,7 +133,11 @@ OPTIONS
{empty}::
If this option is given, the value passed is written to the
preferences file and rememberd for subsequent runs.
preferences file and rememberd for subsequent runs (except when
*--no-save-prefs* is passed).
*--no-save-prefs*::
Do not save any (changed) preferences to *preferences.txt*.
*--upload*::
Build and upload the sketch.
@ -253,6 +259,9 @@ HISTORY
Windows, the splash screen is still shown.
1.5.7::
Introduced *--no-save-prefs*.
{empty}::
*--board* and *--port* options are now saved to the preferences
file, just like *--pref*. The *--verbose* options still only
apply to the current run.