#update #io #latest #fetch #binary #latest-version #cargo

rspawn

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

1 unstable release

new 0.0.3 Dec 15, 2024
0.0.2 Dec 14, 2024
0.0.1 Dec 13, 2024
0.0.0 Dec 13, 2024

#9 in #latest

Download history 436/week @ 2024-12-09

436 downloads per month

GPL-3.0-only

29KB
189 lines

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

Dependencies

~5–16MB
~204K SLoC