aboutsummaryrefslogtreecommitdiff
path: root/mingling_ci/src/progress.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-18 10:59:46 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-18 10:59:46 +0800
commit78776ff4a91c470f075aa5148e48c02ca6e4d050 (patch)
treeb072f4ca72679be50c1fe155b1651ded82cad4e7 /mingling_ci/src/progress.rs
parentb47a1fb1dd5b82ba14bcf8589c5b2a604569bf19 (diff)
refactor(ci-new): extract shared task progress bar helper
Diffstat (limited to 'mingling_ci/src/progress.rs')
-rw-r--r--mingling_ci/src/progress.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/mingling_ci/src/progress.rs b/mingling_ci/src/progress.rs
new file mode 100644
index 0000000..bd62ae1
--- /dev/null
+++ b/mingling_ci/src/progress.rs
@@ -0,0 +1,24 @@
+//! Shared task progress bar.
+
+use colored::Colorize;
+use indicatif::{ProgressBar, ProgressStyle};
+
+/// Creates a task progress bar with the CI's standard style.
+///
+/// `prefix` is the phase label shown before the bar, right-aligned to 12
+/// columns (e.g. `Building`, `Clippy`, `Testing`). The caller sets the
+/// initial message and drives the position.
+pub(crate) fn task_progress_bar(len: usize, prefix: &str) -> ProgressBar {
+ let padding = " ".repeat(12usize.saturating_sub(prefix.len()));
+ let styled_prefix = format!("{padding}{}", prefix.bold().bright_cyan());
+ let pb = ProgressBar::new(len as u64);
+ pb.set_style(
+ ProgressStyle::default_bar()
+ .template(&format!(
+ "{styled_prefix} [{{bar:28}}] {{pos}}/{{len}}: {{msg}}"
+ ))
+ .unwrap()
+ .progress_chars("=> "),
+ );
+ pb
+}