1 //! A tool for installing bootstrapped Rust binaries into the requested paths. 2 3 use std::{ 4 env, 5 fs::{copy, create_dir_all}, 6 path::PathBuf, 7 }; 8 install() -> std::io::Result<u64>9fn install() -> std::io::Result<u64> { 10 let binary = PathBuf::from(env!("RULES_RUST_CARGO_BOOTSTRAP_BINARY")); 11 12 // Consume only the first argument as the destination 13 let dest = PathBuf::from( 14 env::args() 15 .nth(1) 16 .expect("No destination argument provided"), 17 ); 18 19 // Create the parent directory structure if it doesn't exist 20 if let Some(parent) = dest.parent() { 21 if !parent.exists() { 22 create_dir_all(parent)?; 23 } 24 } 25 26 // Copy the file to the requested destination 27 copy(binary, dest) 28 } 29 main()30fn main() { 31 if let Err(err) = install() { 32 eprintln!("{err:?}"); 33 std::process::exit(1); 34 }; 35 } 36