diff --git a/src/main.rs b/src/main.rs index 8791547..a1b247a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -685,7 +685,12 @@ fn main() { .unwrap_or(""); let archive = sub_matches.get_one::("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 let base_url = match ppa.map(pkh::package_info::split_ppa) { diff --git a/src/ui.rs b/src/ui.rs index 6d8cdf4..6b9e425 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -13,10 +13,11 @@ use indicatif::ProgressDrawTarget; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; 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 { ProgressStyle::default_bar() - .template("> {spinner:.blue} {prefix}") + .template("> {spinner:.blue} {prefix}\n {msg}") .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 -/// shared [`MultiProgress`], spinner-style while the work is unsized, -/// transfer-style once a byte or item total is known. The bar is created -/// eagerly (an empty spinner, so the line exists from the first moment) -/// and released on drop. +/// Terminal build view for the pull flow: a two-line bar attached to the +/// shared [`MultiProgress`], the pull headline behind the spinner and the +/// current message (or transfer bar) below. The bar is created eagerly with +/// its headline, so the line exists from the first moment, and released on +/// drop. pub struct PullView { multi: MultiProgress, pb: ProgressBar, } impl PullView { - /// Attach a pull view to `multi` - pub fn new(multi: &MultiProgress) -> Self { + /// Attach a pull view to `multi`; `headline` stays on the spinner line + /// while the messages and progress below it change + pub fn new(multi: &MultiProgress, headline: &str) -> Self { let pb = multi.add(ProgressBar::new(0)); pb.enable_steady_tick(Duration::from_millis(50)); pb.set_style(spinner_style()); + pb.set_prefix(headline.to_string()); Self { multi: multi.clone(), pb,