diff --git a/cmd/mycolog/main.go b/cmd/mycolog/main.go index 7597715..4b1bc4d 100644 --- a/cmd/mycolog/main.go +++ b/cmd/mycolog/main.go @@ -2,6 +2,7 @@ package main import ( "embed" + "flag" "log" "net/http" "time" @@ -27,6 +28,9 @@ func init() { } func main() { + noBrowser := flag.Bool("headless", false, "run mycolog without opening a browser") + flag.Parse() + http.HandleFunc("/", redirectToDefaultPage) http.Handle("/assets/", http.FileServer(http.FS(assets))) http.HandleFunc("/intro", serveIntro) @@ -44,7 +48,9 @@ func main() { http.HandleFunc("/change-species/", handleChangeSpecies) log.Print("Serving mycolog v0.2.0 from port 8080.") - go openInBrowserWhenServing("http://localhost:8080/") + if !*noBrowser { + go openInBrowserWhenServing("http://localhost:8080/") + } log.Fatal(http.ListenAndServe(":8080", nil)) }