changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / rust/lib/tenex/src/util.rs

changeset 698: 96958d3eb5b0
parent: 35ec32058823
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 /// OS-specific browser command. supports Win/Mac/Linux
2 pub fn open_browser(url: &str) {
3  if cfg!(target_os = "windows") {
4  // https://stackoverflow.com/a/49115945
5  std::process::Command::new("rundll32.exe")
6  .args(&["url.dll,FileProtocolHandler", url])
7  .status()
8  .expect("failed to open file");
9  } else if cfg!(target_os = "macos") || cfg!(target_os = "linux") {
10  // https://dwheeler.com/essays/open-files-urls.html
11  #[cfg(target_os = "macos")]
12  let cmd = "open";
13  #[cfg(target_os = "linux")]
14  let cmd = "xdg-open";
15 
16  #[cfg(any(target_os = "macos", target_os = "linux"))]
17  {
18  std::process::Command::new(cmd)
19  .arg(url)
20  .status()
21  .expect("failed to open URL");
22  }
23  } else {
24  unimplemented!() // ignore others
25  }
26 }