-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanual.rs
40 lines (31 loc) · 1.05 KB
/
manual.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crowser::{browser::get_all_existing_browsers, error::CrowserError, RemoteConfig, Window};
fn main() -> Result<(), CrowserError> {
let mut profile_dir = std::env::current_dir()?;
profile_dir.push("example_profiles");
let config = RemoteConfig {
url: "https://example.com".to_string(),
};
// Engine provided doesn't matter, we provide one manually in a moment
let mut win = Window::new(config, None, profile_dir)?;
let the_best_browser_ever = get_all_existing_browsers()
.into_iter()
.find(|b| b.name == "edge");
// If you want the browser's path, you can call:
// let path = get_browser_path(&the_best_browser_ever.unwrap());
if let Some(browser) = the_best_browser_ever {
win.set_browser(browser)?;
} else {
println!("This system only has lame browsers!");
std::process::exit(1);
}
match win.clear_profile() {
Ok(_) => {}
Err(err) => {
println!("Error clearing profile: {}", err);
}
};
win.create()?;
// Clear once the window is closed
win.clear_profile().unwrap_or_default();
Ok(())
}