@@ -268,7 +268,7 @@ static protected void initRequirements() {
268
268
}
269
269
270
270
271
- protected static enum ACTION { GUI , VERIFY , UPLOAD , NOOP };
271
+ protected static enum ACTION { GUI , VERIFY , UPLOAD , NOOP , GET_PREF };
272
272
public Base (String [] args ) throws Exception {
273
273
platform .init (this );
274
274
@@ -322,6 +322,7 @@ public Base(String[] args) throws Exception {
322
322
ACTION action = ACTION .GUI ;
323
323
boolean doVerboseBuild = false ;
324
324
boolean doVerboseUpload = false ;;
325
+ String getPref = null ;
325
326
String selectBoard = null ;
326
327
String selectPort = null ;
327
328
String currentDirectory = System .getProperty ("user.dir" );
@@ -332,6 +333,7 @@ public Base(String[] args) throws Exception {
332
333
actions .put ("--verify" , ACTION .VERIFY );
333
334
actions .put ("--upload" , ACTION .UPLOAD );
334
335
actions .put ("--noop" , ACTION .NOOP );
336
+ actions .put ("--get-pref" , ACTION .GET_PREF );
335
337
336
338
// Check if any files were passed in on the command line
337
339
for (int i = 0 ; i < args .length ; i ++) {
@@ -342,6 +344,12 @@ public Base(String[] args) throws Exception {
342
344
String mess = I18n .format (_ ("Can only pass one of: {0}" ), PApplet .join (valid , ", " ));
343
345
showError (null , mess , 3 );
344
346
}
347
+ if (a == ACTION .GET_PREF ) {
348
+ i ++;
349
+ if (i >= args .length )
350
+ showError (null , _ ("Argument required for --get-pref" ), 3 );
351
+ getPref = args [i ];
352
+ }
345
353
action = a ;
346
354
continue ;
347
355
}
@@ -406,7 +414,7 @@ public Base(String[] args) throws Exception {
406
414
if ((action == ACTION .UPLOAD || action == ACTION .VERIFY ) && filenames .size () != 1 )
407
415
showError (null , _ ("Must specify exactly one sketch file" ), 3 );
408
416
409
- if (action == ACTION .NOOP && filenames .size () != 0 )
417
+ if (( action == ACTION .NOOP || action == ACTION . GET_PREF ) && filenames .size () != 0 )
410
418
showError (null , _ ("Cannot specify any sketch files" ), 3 );
411
419
412
420
if ((action != ACTION .UPLOAD && action != ACTION .VERIFY ) && (doVerboseBuild || doVerboseUpload ))
@@ -493,6 +501,15 @@ public Base(String[] args) throws Exception {
493
501
// Do nothing (intended for only changing preferences)
494
502
System .exit (0 );
495
503
break ;
504
+ case GET_PREF :
505
+ String value = Preferences .get (getPref , null );
506
+ if (value != null ) {
507
+ System .out .println (value );
508
+ System .exit (0 );
509
+ } else {
510
+ System .exit (4 );
511
+ }
512
+ break ;
496
513
}
497
514
}
498
515
0 commit comments