summaryrefslogtreecommitdiff
path: root/internal/flamegraph/liveserver.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-02 08:46:56 +0200
committerPaul Buetow <paul@buetow.org>2026-03-02 08:46:56 +0200
commit717cf6a47cd19cc284b023825a3bac3272ebe171 (patch)
tree5be553754917157311d107538a99e34b2f8aa839 /internal/flamegraph/liveserver.go
parentb3327d17f9f5c7080b05d6d5457cf25550d40ad9 (diff)
Make --open a command template with no defaults
Diffstat (limited to 'internal/flamegraph/liveserver.go')
-rw-r--r--internal/flamegraph/liveserver.go30
1 files changed, 5 insertions, 25 deletions
diff --git a/internal/flamegraph/liveserver.go b/internal/flamegraph/liveserver.go
index dda1af1..de65ee3 100644
--- a/internal/flamegraph/liveserver.go
+++ b/internal/flamegraph/liveserver.go
@@ -7,7 +7,6 @@ import (
"fmt"
"net/http"
"os/exec"
- "runtime"
"strings"
"time"
)
@@ -19,8 +18,7 @@ var liveServerTimeouts = serverTimeouts{
}
type LiveServerOptions struct {
- AutoOpenBrowser bool
- OpenCommand string
+ OpenCommand string
}
var openBrowserURLFn = openBrowserURL
@@ -47,14 +45,14 @@ func ServeLiveWithOptions(ctx context.Context, lt *LiveTrie, interval time.Durat
}
func maybeOpenLiveBrowser(url string, options LiveServerOptions) error {
- if !options.AutoOpenBrowser {
+ if strings.TrimSpace(options.OpenCommand) == "" {
return nil
}
return openBrowserURLFn(url, options.OpenCommand)
}
func openBrowserURL(url, openCommand string) error {
- parts, err := browserOpenCommandParts(runtime.GOOS, openCommand, url)
+ parts, err := browserOpenCommandParts(openCommand, url)
if err != nil {
return err
}
@@ -66,13 +64,8 @@ func openBrowserURL(url, openCommand string) error {
return nil
}
-func browserOpenCommandParts(goos, openCommand, url string) ([]string, error) {
- var parts []string
- if trimmed := strings.TrimSpace(openCommand); trimmed != "" {
- parts = strings.Fields(trimmed)
- } else {
- parts = defaultBrowserCommand(goos)
- }
+func browserOpenCommandParts(openCommand, url string) ([]string, error) {
+ parts := strings.Fields(strings.TrimSpace(openCommand))
if len(parts) == 0 {
return nil, errors.New("empty browser open command")
}
@@ -90,19 +83,6 @@ func browserOpenCommandParts(goos, openCommand, url string) ([]string, error) {
return parts, nil
}
-func defaultBrowserCommand(goos string) []string {
- switch goos {
- case "darwin":
- return []string{"open", "-a", "Firefox"}
- case "linux":
- return []string{"firefox"}
- case "windows":
- return []string{"cmd", "/c", "start"}
- default:
- return []string{"firefox"}
- }
-}
-
func handleLivePage() http.HandlerFunc {
return func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")