package main import ( "context" "flag" "fmt" "log/slog" "os" "os/signal" "syscall" "hth/internal/app" ) func main() { fs := flag.NewFlagSet("hthd", flag.ExitOnError) cfgPath := fs.String("config", "", "path to hthd YAML config") backend := fs.String("backend", "", "override backend: mock|serial|replay") check := fs.Bool("check-config", false, "validate config and profile then exit") _ = fs.Parse(os.Args[1:]) if *cfgPath == "" { fmt.Fprintln(os.Stderr, "hthd: --config is required") os.Exit(2) } if *check { if err := app.CheckConfig(*cfgPath, *backend); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } return } log := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelInfo})) a, err := app.New(*cfgPath, *backend, log) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() if err := a.Run(ctx); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }