Skip to content

Commit

Permalink
Add -headless flag
Browse files Browse the repository at this point in the history
  • Loading branch information
diode authored and codesoap committed Aug 10, 2024
1 parent bd51224 commit 13360f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/mycolog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"embed"
"flag"
"log"
"net/http"
"time"
Expand All @@ -27,6 +28,9 @@ func init() {
}

func main() {
headless := 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)
Expand All @@ -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 !*headless {
go openInBrowserWhenServing("http://localhost:8080/")
}
log.Fatal(http.ListenAndServe(":8080", nil))
}

Expand Down

0 comments on commit 13360f5

Please sign in to comment.