package main import ( "fmt" "log" "os" tea "github.com/charmbracelet/bubbletea" ) func main() { // Setup logging to file f, err := tea.LogToFile("debug.log", "debug") if err != nil { fmt.Println("fatal:", err) os.Exit(1) } defer f.Close() // Initialize Device manager device := NewDevice() // Initial search for device // We do this synchronously at startup for convenience, // but the UI could also handle re-scanning. portName, err := device.FindCardputer() // Initialize UI Model m := InitialModel(device) if err == nil { m.Status = StatusFound log.Printf("Found Cardputer at %s", portName) } else { log.Printf("Cardputer not found at startup: %v", err) // We start in Searching state, user might plug it in later if we implemented auto-scan, // but for now it just shows searching or error. // Since our basic implementation does a one-time scan at start, // if it fails, we might want to let the user retry or just show the state. // The current InitialModel defaults to StatusSearching. // To match original behavior (sort of), if we don't find it, we stay in Searching/Error. // Actually, let's just leave it as StatusSearching or set Error if we want to be explicit. } // Create and run the Bubble Tea program p := tea.NewProgram(m, tea.WithAltScreen()) if _, err := p.Run(); err != nil { log.Fatal("Error running program:", err) } }