#chrome

bin+lib chrome_launcher

Launch google chrome with rust

2 releases

0.1.1 Oct 18, 2024
0.1.0 Oct 18, 2024

#17 in #chrome

Download history 215/week @ 2024-10-13 40/week @ 2024-10-20

255 downloads per month

Apache-2.0

18KB
363 lines

chrome_launcher

Launch chrome using rust.

Note: MacOS is not tested yet.

Installation

With Cargo:

cargo install chrome_launcher

Usage

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);
        }
    }
}

Contributing

  1. Clone the repo
    git clone https://github.com/chouzz/chrome_launcher.git
    
  2. Install cargo package
    cargo build
    
  3. Run test
    cargo test
    

License

chrome_launcher is released under the Apache-2.0 License. See the bundled LICENSE file for details.

Credit

The idea comes from typescript version chrome-launcher

Dependencies

~1.6–9MB
~85K SLoC