mirror of
https://github.com/vhaudiquet/ecrou.git
synced 2026-11-12 22:22:44 +00:00
feat(progress): report uncounted status through the sink
A run blocked on the cache-entry flock was silent: the wait went to the log sink, which renders nowhere by default, so the CLI read as a hang. The Progress trait gains message() - a status line outside the counted-operation protocol, defaulting to a no-op so existing sinks keep compiling - and the flock wait reports what it is waiting for. The CLI renders messages on the active bar and spins one up when no operation is active.
This commit is contained in:
1 parent
89a1028d46
commit
c2e8d82cd3
5 files changed
+42
-7
No files matched your search
@@ -88,4 +88,24 @@ impl Progress for TermProgress {
|
||||
bar.finish_and_clear();
|
||||
}
|
||||
}
|
||||
|
||||
fn message(&self, text: &str) {
|
||||
let mut slot = self.bar.lock().unwrap();
|
||||
if slot.is_none() {
|
||||
// No operation is active: the message becomes a spinner
|
||||
// until the next `begin` replaces it.
|
||||
let pb = ProgressBar::new_spinner();
|
||||
pb.set_style(
|
||||
ProgressStyle::default_spinner()
|
||||
.template("{spinner:.green} {msg}")
|
||||
.unwrap(),
|
||||
);
|
||||
pb.set_message(text.to_string());
|
||||
*slot = Some(pb);
|
||||
return;
|
||||
}
|
||||
if let Some(bar) = &*slot {
|
||||
bar.set_message(text.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user