forge_core_utils/browser.rs
1use crate::is_wsl2;
2
3/// Open URL in browser with WSL2 support
4pub async fn open_browser(url: &str) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5 if is_wsl2() {
6 // In WSL2, use PowerShell to open the browser
7 tokio::process::Command::new("powershell.exe")
8 .arg("-Command")
9 .arg(format!("Start-Process '{url}'"))
10 .spawn()?;
11 Ok(())
12 } else {
13 // Use the standard open crate for other platforms
14 open::that(url).map_err(|e| e.into())
15 }
16}