MCPcopy
hub / github.com/smallstep/cli / OpenInBrowser

Function OpenInBrowser

exec/exec.go:103–127  ·  view source on GitHub ↗

OpenInBrowser opens the given url on a web browser

(url, browser string)

Source from the content-addressed store, hash-verified

101
102// OpenInBrowser opens the given url on a web browser
103func OpenInBrowser(url, browser string) error {
104 var cmd *exec.Cmd
105 switch runtime.GOOS {
106 case "darwin":
107 if browser == "" {
108 cmd = exec.Command("open", url)
109 } else {
110 cmd = exec.Command("open", "-a", browser, url)
111 }
112 case "linux":
113 if IsWSL() {
114 cmd = exec.Command("rundll32.exe", "url.dll,FileProtocolHandler", url)
115 } else {
116 cmd = exec.Command("xdg-open", url)
117 }
118 case "android":
119 cmd = exec.Command("xdg-open", url)
120 case "windows":
121 cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
122 default:
123 return errors.Errorf("unsupported platform '%s'", runtime.GOOS)
124 }
125
126 return errors.WithStack(cmd.Start())
127}
128
129// Step executes step with the given commands and returns the standard output.
130func Step(args ...string) ([]byte, error) {

Callers 1

Calls 1

IsWSLFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…