MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / try_open_browser

Function try_open_browser

crates/opencode-cli/src/main.rs:1879–1910  ·  view source on GitHub ↗
(url: &str)

Source from the content-addressed store, hash-verified

1877}
1878
1879fn 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
1912async fn run_web_command(
1913 port: u16,

Callers 1

run_web_commandFunction · 0.85

Calls 4

newFunction · 0.85
is_emptyMethod · 0.80
statusMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected