MCPcopy Create free account
hub / github.com/alceal/plotlars / open_html_file

Function open_html_file

crates/plotlars-plotly/src/render/mod.rs:100–130  ·  view source on GitHub ↗

Helper function to open an HTML file in the default browser

(path: &std::path::Path)

Source from the content-addressed store, hash-verified

98
99/// Helper function to open an HTML file in the default browser
100pub(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}

Callers 2

plotMethod · 0.85
plotMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected