From 4452eb3850d331c5af24356e6f8e368f7d59acef Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 7 Apr 2014 10:40:45 +0200 Subject: [PATCH] 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. --- app/src/processing/app/Base.java | 4 ++++ app/src/processing/app/Preferences.java | 8 ++++++++ build/shared/manpage.adoc | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index b8524f5f2..4969bd2a5 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -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) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 73b980ef5..119681086 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -220,6 +220,7 @@ public class Preferences { static Hashtable defaults; static Hashtable table = new Hashtable(); 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; + } } diff --git a/build/shared/manpage.adoc b/build/shared/manpage.adoc index 709676b80..12d2bdba9 100644 --- a/build/shared/manpage.adoc +++ b/build/shared/manpage.adoc @@ -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.