rspawn

Crates.iorspawn
lib.rsrspawn
version0.0.3
created_at2024-12-13 01:03:14.272532+00
updated_at2024-12-15 18:57:52.222651+00
descriptionA crate to fetch latest from crates.io and update your binary
homepage
repositoryhttps://github.com/jgabaut/rspawn
max_upload_size
id1481801
size95,339
(jgabaut)

documentation

https://docs.rs/rspawn

README

rspawn

A crate to fetch latest version from crates.io and update your binary.

Similar crates do similar things, but none had the specific mix I needed.

Usage

Run example with cargo run --example usage. See examples/usage.rs:

use rspawn::relaunch_program;
use std::io;

fn main() {

    let custom_confirm = |version: &str| {
        println!("A new version {} is available. Would you like to install it? (yes/n): ", version);

        let mut response = String::new();
        io::stdin().read_line(&mut response).unwrap();
        response.trim().to_lowercase() == "yes"
    };

    #[allow(non_snake_case)]
    let check_if_executed_from_PATH = true; // Only ask for update when called from PATH

    if let Err(e) = relaunch_program(None, Some(custom_confirm), check_if_executed_from_PATH) {
        eprintln!("Error: {}", e);
    }
}
Commit count: 23

cargo fmt