@@ -218,7 +218,7 @@ public String toString() {
218218 static File preferencesFile ;
219219
220220
221- static protected void init (String commandLinePrefs ) {
221+ static protected void init (String args [] ) {
222222
223223 // start by loading the defaults, in case something
224224 // important was deleted from the user prefs
@@ -250,41 +250,31 @@ static protected void init(String commandLinePrefs) {
250250 // clone the hash table
251251 defaults = new Hashtable <String , String >(table );
252252
253- // Load a prefs file if specified on the command line
254- if (commandLinePrefs != null ) {
255- try {
256- load (new FileInputStream (commandLinePrefs ));
257-
258- } catch (Exception poe ) {
259- Base .showError (_ ("Error" ),
260- I18n .format (
261- _ ("Could not read preferences from {0}" ),
262- commandLinePrefs
263- ), poe );
253+ // next load user preferences file
254+ preferencesFile = Base .getSettingsFile (PREFS_FILE );
255+
256+ // load a preferences file if specified on the command line
257+ if (args != null ) {
258+ for (int i = 0 ; i < args .length - 1 ; i ++) {
259+ if (args [i ].equals ("--preferences-file" ))
260+ preferencesFile = new File (args [i + 1 ]);
264261 }
265- } else if (!Base .isCommandLine ()) {
266- // next load user preferences file
267- preferencesFile = Base .getSettingsFile (PREFS_FILE );
268- if (!preferencesFile .exists ()) {
269- // create a new preferences file if none exists
270- // saves the defaults out to the file
271- save ();
272-
273- } else {
274- // load the previous preferences file
275-
276- try {
277- load (new FileInputStream (preferencesFile ));
278-
279- } catch (Exception ex ) {
280- Base .showError (_ ("Error reading preferences" ),
281- I18n .format (
282- _ ("Error reading the preferences file. " +
283- "Please delete (or move)\n " +
284- "{0} and restart Arduino." ),
285- preferencesFile .getAbsolutePath ()
286- ), ex );
287- }
262+ }
263+
264+ if (!preferencesFile .exists ()) {
265+ // create a new preferences file if none exists
266+ // saves the defaults out to the file
267+ save ();
268+ } else {
269+ // load the previous preferences file
270+ try {
271+ load (new FileInputStream (preferencesFile ));
272+ } catch (Exception ex ) {
273+ Base .showError (_ ("Error reading preferences" ),
274+ I18n .format (_ ("Error reading the preferences file. "
275+ + "Please delete (or move)\n "
276+ + "{0} and restart Arduino." ),
277+ preferencesFile .getAbsolutePath ()), ex );
288278 }
289279 }
290280
0 commit comments