Files
homarr/tools/homarr-dev/internal/platform/open.go
T
Thomas Camlong 7710abcf26 feat(cli): rework developer CLI with non-blocking tasks and GitHub CI checks
Rebuild the developer CLI and interactive TUI from the ground up using
Bubble Tea v2, Lip Gloss v2, and non-blocking background workers. Adds
support for background docker pulls with live per-layer byte progress,
build log streaming, interactive container shells, dynamic sidebar
tabs (logs / build / ci), and gh cli integration to view or watch CI checks.
2026-08-21 15:40:04 +02:00

30 lines
819 B
Go

package platform
import (
"fmt"
"os/exec"
"runtime"
)
func OpenURL(url string) error {
name, args, err := openCommand(runtime.GOOS, url)
if err != nil {
return err
}
return exec.Command(name, args...).Start()
}
var platformOpeners = map[string]func(string) (string, []string){
"darwin": func(u string) (string, []string) { return "open", []string{u} },
"linux": func(u string) (string, []string) { return "xdg-open", []string{u} },
"windows": func(u string) (string, []string) { return "rundll32", []string{"url.dll,FileProtocolHandler", u} },
}
func openCommand(goos, url string) (string, []string, error) {
if opener, supported := platformOpeners[goos]; supported {
name, args := opener(url)
return name, args, nil
}
return "", nil, fmt.Errorf("opening URLs is not supported on %s", goos)
}