(url: &str)
| 1877 | } |
| 1878 | |
| 1879 | fn try_open_browser(url: &str) { |
| 1880 | let mut candidates: Vec<Vec<String>> = Vec::new(); |
| 1881 | if cfg!(target_os = "macos") { |
| 1882 | candidates.push(vec!["open".to_string(), url.to_string()]); |
| 1883 | } else if cfg!(target_os = "windows") { |
| 1884 | candidates.push(vec![ |
| 1885 | "cmd".to_string(), |
| 1886 | "/C".to_string(), |
| 1887 | "start".to_string(), |
| 1888 | "".to_string(), |
| 1889 | url.to_string(), |
| 1890 | ]); |
| 1891 | } else { |
| 1892 | candidates.push(vec!["xdg-open".to_string(), url.to_string()]); |
| 1893 | } |
| 1894 | |
| 1895 | for cmd in candidates { |
| 1896 | if cmd.is_empty() { |
| 1897 | continue; |
| 1898 | } |
| 1899 | let status = ProcessCommand::new(&cmd[0]).args(&cmd[1..]).status(); |
| 1900 | if let Ok(status) = status { |
| 1901 | if status.success() { |
| 1902 | return; |
| 1903 | } |
| 1904 | } |
| 1905 | } |
| 1906 | eprintln!( |
| 1907 | "Could not auto-open browser. Open this URL manually: {}", |
| 1908 | url |
| 1909 | ); |
| 1910 | } |
| 1911 | |
| 1912 | async fn run_web_command( |
| 1913 | port: u16, |
no test coverage detected