This commit is contained in:
JMARyA 2025-01-05 01:30:56 +01:00
parent b416507e4a
commit 738c7ed504
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 14 additions and 3 deletions

View file

@ -23,7 +23,11 @@ pub fn ensure_exists(dir: &str) {
} }
pub fn run_backup_rsync(conf: &RsyncConfig) { 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 { if let Some(dir) = &conf.ensure_exists {
ensure_exists(&dir); ensure_exists(&dir);

View file

@ -1,4 +1,5 @@
use backup::run_backup; use backup::run_backup;
use yansi::{Color, Paint};
mod backup; mod backup;
mod config; mod config;
@ -15,7 +16,7 @@ fn main() {
} }
pub fn run_command(cmd: &[&str]) -> (String, String) { 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 = std::process::Command::new(cmd[0]);
let mut cmd_setup = cmd_setup.args(cmd.iter().skip(1).collect::<Vec<_>>()); let mut cmd_setup = cmd_setup.args(cmd.iter().skip(1).collect::<Vec<_>>());
@ -27,7 +28,13 @@ pub fn run_command(cmd: &[&str]) -> (String, String) {
let child = cmd_setup.spawn().unwrap(); let child = cmd_setup.spawn().unwrap();
let status = child.wait_with_output().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 output = String::from_utf8(status.stdout).unwrap();
let stderr = String::from_utf8(status.stderr).unwrap(); let stderr = String::from_utf8(status.stderr).unwrap();