stynx_code_auth/infrastructure/oauth/browser.rs
1use stynx_code_errors::{AppError, AppResult};
2use std::process::Command;
3
4pub fn open_browser(url: &str) -> AppResult<()> {
5 let cmd = if cfg!(target_os = "macos") {
6 "open"
7 } else if cfg!(target_os = "windows") {
8 "start"
9 } else {
10 "xdg-open"
11 };
12
13 Command::new(cmd)
14 .arg(url)
15 .spawn()
16 .map_err(|e| AppError::Provider(format!("failed to open browser with `{cmd}`: {e}")))?;
17
18 Ok(())
19}