package main

import (
	"flag"
	"fmt"
	"os"

	"fn-registry/functions/browser"
)

func main() {
	port := flag.Int("port", 9222, "CDP debug port")
	headless := flag.Bool("headless", false, "headless mode")
	chromePath := flag.String("chrome-path", "", "explicit chrome.exe path (optional)")
	userDataDir := flag.String("user-data-dir", "", "user-data-dir (optional; WSL2 auto-translates)")
	flag.Parse()

	pid, err := browser.ChromeLaunch(browser.ChromeLaunchOpts{
		Port:        *port,
		Headless:    *headless,
		ChromePath:  *chromePath,
		UserDataDir: *userDataDir,
	})
	if err != nil {
		fmt.Fprintf(os.Stderr, "chrome_launch failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("OK pid=%d port=%d\n", pid, *port)
}
