Main function demonstrating enhanced package index functionality
()
| 738 | |
| 739 | |
| 740 | def main() -> None: |
| 741 | """Main function demonstrating enhanced package index functionality""" |
| 742 | print("🚀 ENHANCED ARDUINO PACKAGE INDEX WITH PYDANTIC") |
| 743 | print("=" * 60) |
| 744 | |
| 745 | try: |
| 746 | # Demo model validation |
| 747 | demo_model_validation() |
| 748 | |
| 749 | # Demo ESP32 parsing |
| 750 | package_index = demo_esp32_parsing() |
| 751 | |
| 752 | # Interactive options |
| 753 | try: |
| 754 | print("\n📋 AVAILABLE OPTIONS:") |
| 755 | print("1. Show detailed tools information") |
| 756 | print("2. Search for specific architecture") |
| 757 | print("3. Exit") |
| 758 | |
| 759 | choice = input("\nEnter your choice (1-3): ").strip() |
| 760 | |
| 761 | if choice == "1" and package_index and package_index.packages: |
| 762 | # Simple tools info display (without importing original) |
| 763 | pkg = package_index.packages[0] |
| 764 | print(f"\n🔧 TOOLS INFORMATION for {pkg.name}") |
| 765 | print(f"Total tools: {len(pkg.tools)}") |
| 766 | for tool in pkg.tools[:3]: # Show first 3 tools |
| 767 | print( |
| 768 | f" • {tool.name} v{tool.version} ({len(tool.systems)} systems)" |
| 769 | ) |
| 770 | if len(pkg.tools) > 3: |
| 771 | print(f" ... and {len(pkg.tools) - 3} more tools") |
| 772 | |
| 773 | elif choice == "2" and package_index: |
| 774 | arch = input("Enter architecture to search for: ").strip() |
| 775 | platforms = [ |
| 776 | p |
| 777 | for pkg in package_index.packages |
| 778 | for p in pkg.platforms |
| 779 | if p.architecture == arch |
| 780 | ] |
| 781 | if platforms: |
| 782 | print( |
| 783 | f"\n🔍 Found {len(platforms)} platforms for architecture '{arch}':" |
| 784 | ) |
| 785 | for platform in platforms: |
| 786 | print( |
| 787 | f" • {platform.name} v{platform.version} ({format_size(platform.size_mb)})" |
| 788 | ) |
| 789 | else: |
| 790 | print(f"❌ No platforms found for architecture '{arch}'") |
| 791 | else: |
| 792 | print("👋 Goodbye!") |
| 793 | |
| 794 | except KeyboardInterrupt as ki: |
| 795 | handle_keyboard_interrupt(ki) |
| 796 | raise |
| 797 | print("\n👋 Interrupted by user") |
no test coverage detected