use std::process::Command;
#[cfg(target_os = "linux")]
pub fn open_with_web_browser(path: &str) {
let web_browsers = vec!["firefox", "chromium"];
for browser in web_browsers {
let child = Command::new(browser).args([path]).spawn();
if child.is_ok() {
return;
}
}
}
#[cfg(target_os = "macos")]
pub fn open_with_web_browser(path: &str) {
Command::new("open")
.args(&[path])
.output()
.expect("open() failed, can't open HTML content automatically");
}
#[cfg(target_os = "windows")]
pub fn open_with_web_browser(path: &str) {
Command::new("cmd")
.arg("/C")
.arg(format!(r#"start {}"#, path))
.output()
.expect("failed to open generated HTML content");
}