Crates.io | chrome_launcher |
lib.rs | chrome_launcher |
version | 0.1.1 |
source | src |
created_at | 2024-10-18 07:29:36.091762 |
updated_at | 2024-10-18 07:51:32.861528 |
description | Launch google chrome with rust |
homepage | |
repository | https://github.com/chouzz/chrome_launcher |
max_upload_size | |
id | 1413962 |
size | 41,265 |
Launch chrome using rust.
Note: MacOS is not tested yet.
With Cargo:
cargo install chrome_launcher
Add this to your Cargo.toml
:
[dependencies]
chrome_launcher = "0.1.0"
Code:
mod chrome_launcher;
mod chrome_finder;
mod flags;
mod utils;
use crate::chrome_launcher::Launcher;
use chrome_launcher::Options;
fn main() {
let mut options = Options::default();
options.starting_url = Some("https://google.com".to_string());
let mut launcher = Launcher::new(options);
match launcher.launch() {
Ok(mut launched_chrome) => {
println!("Launched Chrome with PID: {}", launched_chrome.pid);
let _ = launched_chrome.process.wait().map_err(|e| e.to_string()).unwrap();
println!("Chrome process has exited.");
}
Err(e) => {
eprintln!("Error launching Chrome: {}", e);
}
}
}
Clone the repo
git clone https://github.com/chouzz/chrome_launcher.git
Install cargo package
cargo build
Run test
cargo test
chrome_launcher is released under the Apache-2.0 License. See the bundled LICENSE file for details.
The idea comes from typescript version chrome-launcher