From a6657842c417052ee74e8fa693f15ec603811f50 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 24 Jan 2024 13:05:07 +0100 Subject: [PATCH] feat: show current file name in progress bar --- src/checks/osb.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/checks/osb.rs b/src/checks/osb.rs index e98d2fe..a2334b5 100644 --- a/src/checks/osb.rs +++ b/src/checks/osb.rs @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2023 Comprehensive Cancer Center Mainfranken + * Copyright (c) 2024 Comprehensive Cancer Center Mainfranken * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ use std::fs; use std::io::Read; use std::path::Path; -use indicatif::ProgressBar; +use indicatif::{ProgressBar, ProgressStyle}; use crate::checks::{osc, CheckNotice}; @@ -54,11 +54,16 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check let mut result = vec![]; - let progress_bar = ProgressBar::new(archive.len() as u64); + let mut progress_bar = ProgressBar::new(archive.len() as u64).with_style( + ProgressStyle::default_bar() + .template("{wide_bar} {msg:32} {pos}/{len}") + .unwrap(), + ); for i in 0..archive.len() { progress_bar.inc(1); if let Ok(Ok(mut zip_file)) = archive.by_index_decrypt(i, password.as_bytes()) { + progress_bar.set_message(zip_file.name().to_string()); if zip_file.is_file() && zip_file.name().ends_with(".osc") { let mut buf = String::new(); let _ = zip_file.read_to_string(&mut buf); @@ -97,7 +102,7 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check } } else { return Err(CheckNotice::Error { - description: format!("Kann Datei nicht lesen"), + description: "Kann Datei nicht lesen".to_string(), line: None, }); }