| 
35 | 35 | boards_local_txt = None  | 
36 | 36 | if "--boards-local-txt" in sys.argv:  | 
37 | 37 |     COPY_BOARDS_LOCAL_TXT = True  | 
38 |  | -    if sys.argv.index("--boards-local-txt") + 1 >= len(sys.argv):  | 
 | 38 | +    if sys.argv.index("--boards-local-txt") + 1 == len(sys.argv):  | 
39 | 39 |         # check if in cwd  | 
40 | 40 |         if os.path.exists("boards.local.txt"):  | 
41 | 41 |             boards_local_txt = "boards.local.txt"  | 
42 | 42 |         else:  | 
43 | 43 |             sys.stderr.write("Error: --boards-local-txt option requires a path to boards.local.txt file or to be present in current directory\n")  | 
44 | 44 |             sys.exit(1)  | 
45 | 45 |     else:  | 
46 |  | -        # get the boards.local.txt file from the command line  | 
 | 46 | +        # check second arg is file or another flag:  | 
 | 47 | +        if sys.argv[sys.argv.index("--boards-local-txt") + 1].startswith("--"):  | 
 | 48 | +            if os.path.exists("boards.local.txt"):  | 
 | 49 | +                boards_local_txt = "boards.local.txt"  | 
 | 50 | +            else:  | 
 | 51 | +                sys.stderr.write("Error: --boards-local-txt option requires a path to boards.local.txt file (or to be present in current directory)\n")  | 
 | 52 | +                sys.exit(1)  | 
 | 53 | +        # get the boards.local.txt file from the command line (index exists checked earlier)  | 
47 | 54 |         if not os.path.exists(sys.argv[sys.argv.index("--boards-local-txt") + 1]):  | 
48 | 55 |             sys.stderr.write("Error: boards.local.txt file does not exist\n")  | 
49 | 56 |             sys.exit(1)  | 
@@ -482,7 +489,7 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):  | 
482 | 489 |             config_output = subprocess.check_output(["arduino-cli", "config", "dump", "--format", "json"]).decode()  | 
483 | 490 |         config = json.loads(config_output)  | 
484 | 491 |         ColorPrint.print_info(f"Using arduino-cli config: {config_output.strip()}")  | 
485 |  | -          | 
 | 492 | + | 
486 | 493 |         # Extract data directory, with fallback to default  | 
487 | 494 |         data_dir = config.get("directories", {}).get("data", "")  | 
488 | 495 |         if not data_dir:  | 
@@ -529,7 +536,7 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):  | 
529 | 536 |                     # Sort versions and take the latest (could be improved with proper version sorting)  | 
530 | 537 |                     latest_version = sorted(versions)[-1]  | 
531 | 538 |                     platform_path = os.path.join(platform_base, latest_version)  | 
532 |  | -                      | 
 | 539 | + | 
533 | 540 |                     dest_path = os.path.join(platform_path, "boards.local.txt")  | 
534 | 541 |                     shutil.copyfile(boards_local_txt, dest_path)  | 
535 | 542 |                     ColorPrint.print_info(f"Copied boards.local.txt to {dest_path}")  | 
@@ -573,7 +580,7 @@ def main():  | 
573 | 580 |         if COPY_BOARDS_LOCAL_TXT and boards_local_txt:  | 
574 | 581 |             install_boards_local_txt(core_fqbn, boards_local_txt)  | 
575 | 582 |         print('#'*80)  | 
576 |  | -          | 
 | 583 | + | 
577 | 584 |         # Test examples in the platform folder  | 
578 | 585 |         if not IS_LEARNING_SYS:  | 
579 | 586 |             test_examples_in_folder(platform, BUILD_DIR+"/examples")  | 
 | 
0 commit comments