package main

import (
	"fmt"
	"os"

	"telephony-inspector/internal/logger"
	"telephony-inspector/internal/tui"

	tea "github.com/charmbracelet/bubbletea"
)

func main() {
	// Initialize logger
	if err := logger.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "Warning: Could not initialize logger: %v\n", err)
	}
	defer logger.Close()

	logger.Info("Starting Telephony Inspector")

	p := tea.NewProgram(tui.NewModel(), tea.WithAltScreen())
	if _, err := p.Run(); err != nil {
		logger.Error("Program error: %v", err)
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	logger.Info("Telephony Inspector exited normally")
}
