use backup::run_backup; mod backup; mod config; fn main() { let args = std::env::args().collect::>(); if let Some(conf) = args.get(1) { let conf = toml::from_str(&std::fs::read_to_string(conf).unwrap()).unwrap(); run_backup(conf); } else { println!("Usage: bk "); } } pub fn run_command(cmd: &[&str]) -> (String, String) { println!("--> {} ", cmd.join(" ")); let mut cmd_setup = std::process::Command::new(cmd[0]); let mut cmd_setup = cmd_setup.args(cmd.iter().skip(1).collect::>()); cmd_setup = cmd_setup .stdout(std::process::Stdio::inherit()) .stdin(std::process::Stdio::inherit()); let child = cmd_setup.spawn().unwrap(); let status = child.wait_with_output().unwrap(); assert!(status.status.success()); let output = String::from_utf8(status.stdout).unwrap(); let stderr = String::from_utf8(status.stderr).unwrap(); if !stderr.trim().is_empty() { eprintln!("{stderr}"); } (output, stderr) }