#!/usr/bin/env python3
from pathlib import Path

from hil_common import main_guard, pio_command, run_checked


def main() -> int:
    print("Stable serial candidates (listing only; no device is opened):")
    by_id = Path("/dev/serial/by-id")
    candidates = sorted(by_id.iterdir()) if by_id.is_dir() else []
    if not candidates:
        print("  none")
    for candidate in candidates:
        print(f"  {candidate} -> {candidate.resolve()}")
    print("\nPlatformIO discovery (metadata only):")
    run_checked([pio_command(), "device", "list"])
    return 0


if __name__ == "__main__":
    main_guard(main)
