Skip to content

Commit 4452eb3

Browse files
matthijskooijmancmaglie
authored andcommitted
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.
1 parent bbd0128 commit 4452eb3

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

app/src/processing/app/Base.java

+4
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ public Base(String[] args) throws Exception {
385385
processPrefArgument(args[i]);
386386
continue;
387387
}
388+
if (args[i].equals("--no-save-prefs")) {
389+
Preferences.setDoSave(false);
390+
continue;
391+
}
388392
if (args[i].equals("--preferences-file")) {
389393
i++;
390394
if (i >= args.length)

app/src/processing/app/Preferences.java

+8
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public String toString() {
220220
static Hashtable<String, String> defaults;
221221
static Hashtable<String, String> table = new Hashtable<String, String>();
222222
static File preferencesFile;
223+
static boolean doSave = true;
223224

224225

225226
static protected void init(String args[]) {
@@ -789,6 +790,7 @@ static public String[] loadStrings(InputStream input) {
789790

790791

791792
static protected void save() {
793+
if (!doSave) return;
792794
// try {
793795
// on startup, don't worry about it
794796
// this is trying to update the prefs for who is open
@@ -989,4 +991,10 @@ static public PreferencesMap getMap()
989991
return new PreferencesMap(table);
990992
}
991993

994+
// Decide wether changed preferences will be saved. When value is
995+
// false, Preferences.save becomes a no-op.
996+
static public void setDoSave(boolean value)
997+
{
998+
doSave = value;
999+
}
9921000
}

build/shared/manpage.adoc

+12-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ OPTIONS
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).
7878
If this option is given, the value passed is written to the
79-
preferences file and rememberd for subsequent runs.
79+
preferences file and rememberd for subsequent runs (except when
80+
*--no-save-prefs* is passed).
8081

8182
*--port* __portname__::
8283
Select the serial port to perform upload of the sketch.
@@ -88,7 +89,8 @@ OPTIONS
8889
If this option is not passed, the value from the current
8990
preferences is used (e.g., the last port selected in the IDE).
9091
If this option is given, the value passed is written to the
91-
preferences file and rememberd for subsequent runs.
92+
preferences file and rememberd for subsequent runs (except when
93+
*--no-save-prefs* is passed).
9294

9395
*--verbose-build*::
9496
Enable verbose mode during build. If this option is not given,
@@ -131,7 +133,11 @@ OPTIONS
131133

132134
{empty}::
133135
If this option is given, the value passed is written to the
134-
preferences file and rememberd for subsequent runs.
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*.
135141

136142
*--upload*::
137143
Build and upload the sketch.
@@ -253,6 +259,9 @@ HISTORY
253259
Windows, the splash screen is still shown.
254260
255261
1.5.7::
262+
Introduced *--no-save-prefs*.
263+
264+
{empty}::
256265
*--board* and *--port* options are now saved to the preferences
257266
file, just like *--pref*. The *--verbose* options still only
258267
apply to the current run.

0 commit comments

Comments
 (0)