Truncate long messages in the progress bar (#214)

* Truncate long messages in the progress bar
This commit is contained in:
sigmaSd 2021-12-14 02:40:52 +01:00 committed by GitHub
parent add6a595bd
commit a3d3e5d1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,9 +63,9 @@ impl Progress {
thread::spawn(move || { thread::spawn(move || {
let template = { let template = {
let mut t = String::new(); let mut t = String::new();
t += "{prefix} [{elapsed_precise}] "; t += "{wide_msg} [{elapsed_precise}] ";
if precise && current_position_fn.is_some() { if precise && current_position_fn.is_some() {
t += "[{wide_bar:.cyan/blue}] "; t += "[{bar:.cyan/blue}] ";
} else { } else {
t += "{spinner:.green} "; t += "{spinner:.green} ";
} }
@ -88,7 +88,7 @@ impl Progress {
pb.tick(); pb.tick();
} }
if let Ok(msg) = msg_rx.try_recv() { if let Ok(msg) = msg_rx.try_recv() {
pb.set_prefix(msg); pb.set_message(msg);
} }
thread::sleep(Duration::from_millis(100)); thread::sleep(Duration::from_millis(100));
} }