pull,ui: show the pull headline beside the spinner

PullView routed its messages into {msg}, but the spinner template only rendered {prefix}, so every unsized phase showed a bare spinner. The transfer template rendered {msg} on its own line under an empty prefix, leaving the bar under a spinner with no context.

Give the view a headline ("Pulling package <name> from <series>..."), render it beside the spinner, and put the current message or transfer bar below it. This matches the deb view's two-line layout.
This commit is contained in:
vhaudiquet committed 2026-11-24 18:35:17 +01:00
1 parent fb61df35fe
commit 1af528f407
2 files changed
+18 -10

No files matched your search

+6 -1
View File
@@ -685,7 +685,12 @@ fn main() {
.unwrap_or(""); .unwrap_or("");
let archive = sub_matches.get_one::<bool>("archive").unwrap_or(&false); let archive = sub_matches.get_one::<bool>("archive").unwrap_or(&false);
let view = pkh::ui::PullView::new(&multi); let origin = series
.or(dist)
.map(|origin| format!(" from {origin}"))
.unwrap_or_default();
let view =
pkh::ui::PullView::new(&multi, &format!("Pulling package {package}{origin}..."));
// Convert PPA to base URL if provided // Convert PPA to base URL if provided
let base_url = match ppa.map(pkh::package_info::split_ppa) { let base_url = match ppa.map(pkh::package_info::split_ppa) {
+12 -9
View File
@@ -13,10 +13,11 @@ use indicatif::ProgressDrawTarget;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use std::time::Duration; use std::time::Duration;
/// Style of an unsized operation: spinner and prefix on one line /// Style of an unsized operation: the headline behind the spinner on the
/// first line, the current message on its own indented line below
pub(crate) fn spinner_style() -> ProgressStyle { pub(crate) fn spinner_style() -> ProgressStyle {
ProgressStyle::default_bar() ProgressStyle::default_bar()
.template("> {spinner:.blue} {prefix}") .template("> {spinner:.blue} {prefix}\n {msg}")
.unwrap() .unwrap()
} }
@@ -106,22 +107,24 @@ pub fn removal_progress(bar: &ProgressBar, idx: usize, count: usize, done: u64)
} }
} }
/// Terminal build view for the pull flow: one bar line attached to the /// Terminal build view for the pull flow: a two-line bar attached to the
/// shared [`MultiProgress`], spinner-style while the work is unsized, /// shared [`MultiProgress`], the pull headline behind the spinner and the
/// transfer-style once a byte or item total is known. The bar is created /// current message (or transfer bar) below. The bar is created eagerly with
/// eagerly (an empty spinner, so the line exists from the first moment) /// its headline, so the line exists from the first moment, and released on
/// and released on drop. /// drop.
pub struct PullView { pub struct PullView {
multi: MultiProgress, multi: MultiProgress,
pb: ProgressBar, pb: ProgressBar,
} }
impl PullView { impl PullView {
/// Attach a pull view to `multi` /// Attach a pull view to `multi`; `headline` stays on the spinner line
pub fn new(multi: &MultiProgress) -> Self { /// while the messages and progress below it change
pub fn new(multi: &MultiProgress, headline: &str) -> Self {
let pb = multi.add(ProgressBar::new(0)); let pb = multi.add(ProgressBar::new(0));
pb.enable_steady_tick(Duration::from_millis(50)); pb.enable_steady_tick(Duration::from_millis(50));
pb.set_style(spinner_style()); pb.set_style(spinner_style());
pb.set_prefix(headline.to_string());
Self { Self {
multi: multi.clone(), multi: multi.clone(),
pb, pb,