Helper function to open an HTML file in the default browser
(path: &std::path::Path)
| 98 | |
| 99 | /// Helper function to open an HTML file in the default browser |
| 100 | pub(crate) fn open_html_file(path: &std::path::Path) { |
| 101 | #[cfg(target_os = "macos")] |
| 102 | { |
| 103 | let _ = Command::new("open").arg(path).spawn().map(|mut child| { |
| 104 | let _ = std::thread::spawn(move || { |
| 105 | let _ = child.wait(); |
| 106 | }); |
| 107 | }); |
| 108 | } |
| 109 | |
| 110 | #[cfg(target_os = "linux")] |
| 111 | { |
| 112 | let _ = Command::new("xdg-open").arg(path).spawn().map(|mut child| { |
| 113 | let _ = std::thread::spawn(move || { |
| 114 | let _ = child.wait(); |
| 115 | }); |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | #[cfg(target_os = "windows")] |
| 120 | { |
| 121 | let _ = Command::new("cmd") |
| 122 | .args(&["/C", "start", "", path.to_str().unwrap()]) |
| 123 | .spawn() |
| 124 | .map(|mut child| { |
| 125 | let _ = std::thread::spawn(move || { |
| 126 | let _ = child.wait(); |
| 127 | }); |
| 128 | }); |
| 129 | } |
| 130 | } |