Main function.
()
| 462 | |
| 463 | |
| 464 | def main() -> int: |
| 465 | """Main function.""" |
| 466 | args = parse_args() |
| 467 | |
| 468 | if args.supported_boards: |
| 469 | print(",".join(DEFAULT_BOARDS_NAMES)) |
| 470 | return 0 |
| 471 | |
| 472 | # Determine which boards to compile for |
| 473 | if args.interactive: |
| 474 | boards_names = choose_board_interactively( |
| 475 | DEFAULT_BOARDS_NAMES + OTHER_BOARDS_NAMES |
| 476 | ) |
| 477 | else: |
| 478 | boards_names = args.boards.split(",") if args.boards else DEFAULT_BOARDS_NAMES |
| 479 | |
| 480 | # Get board objects |
| 481 | boards: list[Board] = [] |
| 482 | for board_name in boards_names: |
| 483 | try: |
| 484 | board = create_board(board_name, no_project_options=False) |
| 485 | boards.append(board) |
| 486 | except KeyboardInterrupt as ki: |
| 487 | handle_keyboard_interrupt(ki) |
| 488 | raise |
| 489 | except Exception as e: |
| 490 | locked_print(f"ERROR: Failed to get board '{board_name}': {e}") |
| 491 | return 1 |
| 492 | |
| 493 | # Determine which examples to compile |
| 494 | if args.positional_examples: |
| 495 | # Convert positional examples, handling both "examples/Blink" and "Blink" formats |
| 496 | examples = [] |
| 497 | for example in args.positional_examples: |
| 498 | # Remove "examples/" prefix if present |
| 499 | if example.startswith("examples/"): |
| 500 | example = example[len("examples/") :] |
| 501 | examples.append(example) |
| 502 | elif args.examples: |
| 503 | examples = args.examples.split(",") |
| 504 | else: |
| 505 | examples = DEFAULT_EXAMPLES |
| 506 | |
| 507 | # Process example exclusions |
| 508 | if args.exclude_examples: |
| 509 | exclude_examples = args.exclude_examples.split(",") |
| 510 | examples = [ex for ex in examples if ex not in exclude_examples] |
| 511 | |
| 512 | # Resolve example paths |
| 513 | example_paths: list[Path] = [] |
| 514 | for example in examples: |
| 515 | try: |
| 516 | example_path = resolve_example_path(example) |
| 517 | example_paths.append(example_path) |
| 518 | except FileNotFoundError as e: |
| 519 | locked_print(f"ERROR: {e}") |
| 520 | return 1 |
| 521 |
no test coverage detected