changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 189: 3d78bed56188
parent: 0ccbbd142694
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 02 Feb 2024 19:47:03 -0500
permissions: -rw-r--r--
description: apply clippy fixes
1 //! Tenex utilities
2 // re-exports
3 pub use futures_util::StreamExt;
4 #[cfg(feature = "indicatif")]
5 pub use indicatif;
6 #[cfg(feature = "oauth2")]
7 pub use oauth2;
8 /// OS-specific browser command. supports Win/Mac/Linux
9 pub fn open_browser(url: &str) {
10  if cfg!(target_os = "windows") {
11  // https://stackoverflow.com/a/49115945
12  std::process::Command::new("rundll32.exe")
13  .args(["url.dll,FileProtocolHandler", url])
14  .status()
15  .expect("failed to open file");
16  } else if cfg!(target_os = "macos") || cfg!(target_os = "linux") {
17  // https://dwheeler.com/essays/open-files-urls.html
18  #[cfg(target_os = "macos")]
19  let cmd = "open";
20  #[cfg(target_os = "linux")]
21  let cmd = "xdg-open";
22 
23  #[cfg(any(target_os = "macos", target_os = "linux"))]
24  {
25  std::process::Command::new(cmd)
26  .arg(url)
27  .status()
28  .expect("failed to open URL");
29  }
30  } else {
31  unimplemented!() // ignore others
32  }
33 }