MCPcopy Index your code
hub / github.com/nikivdev/go / activeSafariURL

Function activeSafariURL

cli/flow/main.go:2289–2313  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2287}
2288
2289func activeSafariURL() (string, error) {
2290 if _, err := exec.LookPath("osascript"); err != nil {
2291 return "", fmt.Errorf("osascript not found in PATH: %w", err)
2292 }
2293
2294 script := `tell application "Safari"
2295 if it is running then
2296 if exists front document then
2297 return URL of front document
2298 end if
2299 end if
2300end tell`
2301 cmd := exec.Command("osascript", "-e", script)
2302 output, err := cmd.Output()
2303 if err != nil {
2304 return "", fmt.Errorf("osascript Safari URL: %w", err)
2305 }
2306
2307 url := strings.TrimSpace(string(output))
2308 if url == "" {
2309 return "", fmt.Errorf("Safari has no active tab URL")
2310 }
2311
2312 return url, nil
2313}
2314
2315func runDeploy(ctx *snap.Context) error {
2316 if ctx.NArgs() != 0 {

Callers 1

runCloneAndOpenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected