@@ -268,7 +268,7 @@ static protected void initRequirements() {
268268 }
269269
270270
271- protected static enum ACTION { GUI , VERIFY , UPLOAD , NOOP };
271+ protected static enum ACTION { GUI , VERIFY , UPLOAD , NOOP , GET_PREF };
272272 public Base (String [] args ) throws Exception {
273273 platform .init (this );
274274
@@ -322,6 +322,7 @@ public Base(String[] args) throws Exception {
322322 ACTION action = ACTION .GUI ;
323323 boolean doVerboseBuild = false ;
324324 boolean doVerboseUpload = false ;;
325+ String getPref = null ;
325326 String selectBoard = null ;
326327 String selectPort = null ;
327328 String currentDirectory = System .getProperty ("user.dir" );
@@ -332,6 +333,7 @@ public Base(String[] args) throws Exception {
332333 actions .put ("--verify" , ACTION .VERIFY );
333334 actions .put ("--upload" , ACTION .UPLOAD );
334335 actions .put ("--noop" , ACTION .NOOP );
336+ actions .put ("--get-pref" , ACTION .GET_PREF );
335337
336338 // Check if any files were passed in on the command line
337339 for (int i = 0 ; i < args .length ; i ++) {
@@ -342,6 +344,12 @@ public Base(String[] args) throws Exception {
342344 String mess = I18n .format (_ ("Can only pass one of: {0}" ), PApplet .join (valid , ", " ));
343345 showError (null , mess , 3 );
344346 }
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+ }
345353 action = a ;
346354 continue ;
347355 }
@@ -406,7 +414,7 @@ public Base(String[] args) throws Exception {
406414 if ((action == ACTION .UPLOAD || action == ACTION .VERIFY ) && filenames .size () != 1 )
407415 showError (null , _ ("Must specify exactly one sketch file" ), 3 );
408416
409- if (action == ACTION .NOOP && filenames .size () != 0 )
417+ if (( action == ACTION .NOOP || action == ACTION . GET_PREF ) && filenames .size () != 0 )
410418 showError (null , _ ("Cannot specify any sketch files" ), 3 );
411419
412420 if ((action != ACTION .UPLOAD && action != ACTION .VERIFY ) && (doVerboseBuild || doVerboseUpload ))
@@ -493,6 +501,15 @@ public Base(String[] args) throws Exception {
493501 // Do nothing (intended for only changing preferences)
494502 System .exit (0 );
495503 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 ;
496513 }
497514 }
498515
0 commit comments