@@ -218,7 +218,7 @@ public String toString() {
218
218
static File preferencesFile ;
219
219
220
220
221
- static protected void init (String commandLinePrefs ) {
221
+ static protected void init (String args [] ) {
222
222
223
223
// start by loading the defaults, in case something
224
224
// important was deleted from the user prefs
@@ -250,41 +250,31 @@ static protected void init(String commandLinePrefs) {
250
250
// clone the hash table
251
251
defaults = new Hashtable <String , String >(table );
252
252
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 ]);
264
261
}
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 );
288
278
}
289
279
}
290
280
0 commit comments