pull,ui,report: render the pull downloads as byte progress
The pull downloads reported through the plain count port only because
byte_progress landed on main after the branch was cut. PullView now
implements it with a byte-counter template in the transfer-style
family (same shape, {bytes}/{total_bytes} counters, human-formatted by
indicatif), downloads emit through it, and the trait doc lists the
event among the ones the pull flow emits — un-duplicating the merged
'message, progress and progress' sentence.
This commit is contained in:
@@ -41,6 +41,17 @@ pub(crate) fn transfer_style() -> ProgressStyle {
|
||||
.progress_chars("=> ")
|
||||
}
|
||||
|
||||
/// [`transfer_style`] with human-formatted byte counters, for the events
|
||||
/// reported through [`crate::report::BuildView::byte_progress`]
|
||||
pub(crate) fn byte_style() -> ProgressStyle {
|
||||
ProgressStyle::default_bar()
|
||||
.template(
|
||||
"> {spinner:.blue} {prefix}\n {msg} [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({eta})",
|
||||
)
|
||||
.unwrap()
|
||||
.progress_chars("=> ")
|
||||
}
|
||||
|
||||
/// A standalone spinner for one-line waits outside a build view (the
|
||||
/// prune size pass): braille frames over the message behind the `> `
|
||||
/// prompt prefix, drawn only on terminals. Callers finish it with
|
||||
@@ -142,6 +153,17 @@ impl crate::report::BuildView for PullView {
|
||||
self.pb.set_position(pos as u64);
|
||||
}
|
||||
|
||||
fn byte_progress(&self, label: &str, pos: u64, total: u64) {
|
||||
if pos != 0 && total != 0 {
|
||||
self.pb.set_style(byte_style());
|
||||
} else {
|
||||
self.pb.set_style(spinner_style());
|
||||
}
|
||||
self.pb.set_message(label.to_string());
|
||||
self.pb.set_length(total);
|
||||
self.pb.set_position(pos);
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user