From 738c7ed5047cd2b9ce5338d86212800157d4dded Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 5 Jan 2025 01:30:56 +0100 Subject: [PATCH] update --- src/backup.rs | 6 +++++- src/main.rs | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backup.rs b/src/backup.rs index 2ea1300..f20a43c 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -23,7 +23,11 @@ pub fn ensure_exists(dir: &str) { } pub fn run_backup_rsync(conf: &RsyncConfig) { - println!("Running backup for {} -> {}", conf.src, conf.dest); + println!( + "Running backup for {} -> {}", + conf.src.paint(Color::Blue), + conf.dest.paint(Color::Yellow) + ); if let Some(dir) = &conf.ensure_exists { ensure_exists(&dir); diff --git a/src/main.rs b/src/main.rs index 9134acf..e77455a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use backup::run_backup; +use yansi::{Color, Paint}; mod backup; mod config; @@ -15,7 +16,7 @@ fn main() { } pub fn run_command(cmd: &[&str]) -> (String, String) { - println!("--> {} ", cmd.join(" ")); + println!("--> {} ", cmd.join(" ").paint(Color::Blue)); let mut cmd_setup = std::process::Command::new(cmd[0]); let mut cmd_setup = cmd_setup.args(cmd.iter().skip(1).collect::>()); @@ -27,7 +28,13 @@ pub fn run_command(cmd: &[&str]) -> (String, String) { let child = cmd_setup.spawn().unwrap(); let status = child.wait_with_output().unwrap(); - assert!(status.status.success()); + if !status.status.success() { + println!( + "{} Command {} returned with non zero exit code.", + "Error:".paint(Color::Red), + cmd.join(" ") + ); + } let output = String::from_utf8(status.stdout).unwrap(); let stderr = String::from_utf8(status.stderr).unwrap();