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