@@ -324,6 +324,7 @@ public Base(String[] args) throws Exception {
324324 boolean doVerbose = false ;
325325 String selectBoard = null ;
326326 String selectPort = null ;
327+ String currentDirectory = System .getProperty ("user.dir" );
327328 // Check if any files were passed in on the command line
328329 for (int i = 0 ; i < args .length ; i ++) {
329330 if (args [i ].equals ("--upload" )) {
@@ -350,6 +351,12 @@ public Base(String[] args) throws Exception {
350351 selectPort = args [i ];
351352 continue ;
352353 }
354+ if (args [i ].equals ("--curdir" )) {
355+ i ++;
356+ if (i < args .length )
357+ currentDirectory = args [i ];
358+ continue ;
359+ }
353360 String path = args [i ];
354361 // Fix a problem with systems that use a non-ASCII languages. Paths are
355362 // being passed in with 8.3 syntax, which makes the sketch loader code
@@ -363,6 +370,9 @@ public Base(String[] args) throws Exception {
363370 e .printStackTrace ();
364371 }
365372 }
373+ if (!new File (path ).isAbsolute ()) {
374+ path = new File (currentDirectory , path ).getAbsolutePath ();
375+ }
366376 if (handleOpen (path ) != null ) {
367377 opened = true ;
368378 }
@@ -386,7 +396,7 @@ public Base(String[] args) throws Exception {
386396
387397 // Do board selection if requested
388398 if (selectBoard != null )
389- selectBoard (selectBoard , editor );
399+ selectBoard (selectBoard );
390400
391401 if (doUpload ) {
392402 // Build and upload
@@ -1292,9 +1302,7 @@ public void rebuildBoardsMenu(JMenu toolsMenu, Editor editor) throws Exception {
12921302
12931303 // Cycle through all boards of this platform
12941304 for (TargetBoard board : targetPlatform .getBoards ().values ()) {
1295- JMenuItem item = createBoardMenusAndCustomMenus (
1296- editor ,
1297- menuItemsToClickAfterStartup ,
1305+ JMenuItem item = createBoardMenusAndCustomMenus (menuItemsToClickAfterStartup ,
12981306 buttonGroupsMap ,
12991307 board , targetPlatform , targetPackage );
13001308 boardsMenu .add (item );
@@ -1314,10 +1322,9 @@ public void rebuildBoardsMenu(JMenu toolsMenu, Editor editor) throws Exception {
13141322 }
13151323
13161324 private JRadioButtonMenuItem createBoardMenusAndCustomMenus (
1317- final Editor editor ,
1318- List <JMenuItem > menuItemsToClickAfterStartup ,
1319- Map <String , ButtonGroup > buttonGroupsMap ,
1320- TargetBoard board , TargetPlatform targetPlatform , TargetPackage targetPackage )
1325+ List <JMenuItem > menuItemsToClickAfterStartup ,
1326+ Map <String , ButtonGroup > buttonGroupsMap ,
1327+ TargetBoard board , TargetPlatform targetPlatform , TargetPackage targetPackage )
13211328 throws Exception {
13221329 String selPackage = Preferences .get ("target_package" );
13231330 String selPlatform = Preferences .get ("target_platform" );
@@ -1331,7 +1338,7 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
13311338 @ SuppressWarnings ("serial" )
13321339 Action action = new AbstractAction (board .getName ()) {
13331340 public void actionPerformed (ActionEvent actionevent ) {
1334- selectBoard ((String ) getValue ("b" ), editor );
1341+ selectBoard ((String ) getValue ("b" ));
13351342 }
13361343 };
13371344 action .putValue ("b" , packageName + ":" + platformName + ":" + boardId );
@@ -1360,7 +1367,7 @@ public void actionPerformed(ActionEvent e) {
13601367 Preferences .set ("target_package" , (String ) getValue ("package" ));
13611368 Preferences .set ("target_platform" , (String ) getValue ("platform" ));
13621369 Preferences .set ("board" , (String ) getValue ("board" ));
1363- Preferences .set ("custom_" + menuId , ( String ) getValue ("board" ) + "_" + ( String ) getValue ("custom_menu_option" ));
1370+ Preferences .set ("custom_" + menuId , getValue ("board" ) + "_" + getValue ("custom_menu_option" ));
13641371
13651372 filterVisibilityOfSubsequentBoardMenus ((String ) getValue ("board" ), currentIndex );
13661373
@@ -1472,13 +1479,22 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
14721479 }
14731480
14741481
1475- private void selectBoard (String selectBoard , Editor editor ) {
1482+ private void selectBoard (String selectBoard ) {
14761483 String [] split = selectBoard .split (":" );
14771484 Preferences .set ("target_package" , split [0 ]);
14781485 Preferences .set ("target_platform" , split [1 ]);
1479- Preferences .set ("board" , split [2 ]);
1486+ String boardId = split [2 ];
1487+ Preferences .set ("board" , boardId );
1488+
1489+ if (split .length > 3 ) {
1490+ String [] customsParts = split [3 ].split ("," );
1491+ for (String customParts : customsParts ) {
1492+ String [] keyValue = customParts .split ("=" );
1493+ Preferences .set ("custom_" + keyValue [0 ].trim (), boardId + "_" + keyValue [1 ].trim ());
1494+ }
1495+ }
14801496
1481- filterVisibilityOfSubsequentBoardMenus (split [ 2 ] , 1 );
1497+ filterVisibilityOfSubsequentBoardMenus (boardId , 1 );
14821498
14831499 onBoardOrPortChange ();
14841500 Sketch .buildSettingChanged ();
0 commit comments