1package main
 2
 3import (
 4	"log/slog"
 5	"net/http"
 6	"os"
 7
 8	_ "net/http/pprof" // profiling
 9
10	_ "github.com/joho/godotenv/autoload" // automatically load .env files
11
12	"github.com/charmbracelet/crush/cmd"
13	"github.com/charmbracelet/crush/internal/log"
14)
15
16func main() {
17	defer log.RecoverPanic("main", func() {
18		slog.Error("Application terminated due to unhandled panic")
19	})
20
21	if os.Getenv("CRUSH_PROFILE") != "" {
22		go func() {
23			slog.Info("Serving pprof at localhost:6060")
24			if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
25				slog.Error("Failed to pprof listen", "error", httpErr)
26			}
27		}()
28	}
29
30	cmd.Execute()
31}