Command-line interface for client.
()
| 565 | |
| 566 | |
| 567 | def main() -> int: |
| 568 | """Command-line interface for client.""" |
| 569 | import argparse |
| 570 | |
| 571 | parser = argparse.ArgumentParser( |
| 572 | description="PlatformIO Package Installation Client" |
| 573 | ) |
| 574 | parser.add_argument("--status", action="store_true", help="Show daemon status") |
| 575 | parser.add_argument("--stop", action="store_true", help="Stop the daemon") |
| 576 | parser.add_argument( |
| 577 | "--test-request", |
| 578 | action="store_true", |
| 579 | help="Submit test request to daemon", |
| 580 | ) |
| 581 | parser.add_argument( |
| 582 | "--project-dir", |
| 583 | type=Path, |
| 584 | help="PlatformIO project directory", |
| 585 | ) |
| 586 | parser.add_argument( |
| 587 | "--environment", |
| 588 | help="PlatformIO environment", |
| 589 | ) |
| 590 | parser.add_argument( |
| 591 | "--timeout", |
| 592 | type=int, |
| 593 | default=1800, |
| 594 | help="Timeout in seconds (default: 1800)", |
| 595 | ) |
| 596 | |
| 597 | args = parser.parse_args() |
| 598 | |
| 599 | if args.status: |
| 600 | status = get_daemon_status() |
| 601 | print("Daemon Status:") |
| 602 | print(json.dumps(status, indent=2)) |
| 603 | return 0 |
| 604 | |
| 605 | if args.stop: |
| 606 | return 0 if stop_daemon() else 1 |
| 607 | |
| 608 | if args.test_request: |
| 609 | # Use current directory as test |
| 610 | project_dir = Path.cwd() |
| 611 | if not (project_dir / "platformio.ini").exists(): |
| 612 | print("❌ No platformio.ini found in current directory") |
| 613 | return 1 |
| 614 | |
| 615 | success = ensure_packages_installed( |
| 616 | project_dir, |
| 617 | args.environment, |
| 618 | args.timeout, |
| 619 | ) |
| 620 | return 0 if success else 1 |
| 621 | |
| 622 | if args.project_dir: |
| 623 | success = ensure_packages_installed( |
| 624 | args.project_dir, |
no test coverage detected