From 670e17d2e49d3cc383089312c953ed9cc6c02088 Mon Sep 17 00:00:00 2001 From: Abdulla Abdurakhmanov Date: Sun, 1 Sep 2024 11:53:00 +0200 Subject: [PATCH] Results output update --- src/main.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 84ce087..85b2aa0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,35 +86,35 @@ async fn handle_args(cli: CliArgs, term: &Term) -> AppResult<()> { redacter_args.map(|args| args.try_into()).transpose()?, ) .await?; + if let Some(json_path) = save_json_results { + let json_result = serde_json::to_string_pretty(©_result)?; + let mut file = tokio::fs::File::create(&json_path).await?; + tokio::io::AsyncWriteExt::write_all(&mut file, json_result.as_bytes()).await?; + term.write_line( + format!( + "Results saved to JSON file: {}", + Style::new().bold().apply_to(json_path.display()) + ) + .as_str(), + )?; + } term.write_line( format!( - "\n{} -> {}: {} files copied ({} redacted). {} files skipped.", - source, - destination, + "Finished: {} -> {}\nCopied: {}. Redacted: {}. Skipped: {}.", + Style::new().bold().apply_to(source), + Style::new().green().apply_to(destination), Style::new() .bold() .green() .apply_to(copy_result.files_copied), Style::new() + .bold() .green() - .dim() .apply_to(copy_result.files_redacted), Style::new().yellow().apply_to(copy_result.files_skipped), ) .as_str(), )?; - if let Some(json_path) = save_json_results { - let json_result = serde_json::to_string_pretty(©_result)?; - let mut file = tokio::fs::File::create(&json_path).await?; - tokio::io::AsyncWriteExt::write_all(&mut file, json_result.as_bytes()).await?; - term.write_line( - format!( - "Results saved to JSON file: {}", - Style::new().bold().apply_to(json_path.display()) - ) - .as_str(), - )?; - } } CliCommand::Ls { source,