Show percentage in changelog generator example

This commit is contained in:
Héctor Ramón Jiménez 2025-12-03 05:23:46 +01:00
parent 4fc97c2ba6
commit 82544c39ca
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -241,15 +241,13 @@ impl Generator {
} => { } => {
let progress = { let progress = {
let total = pending.len() + changelog.len(); let total = pending.len() + changelog.len();
let percent = 100.0 * changelog.len() as f32 / total as f32;
let bar = progress_bar( let bar = progress_bar(0.0..=100.0, percent)
0.0..=1.0, .style(progress_bar::secondary);
changelog.len() as f32 / total as f32,
)
.style(progress_bar::secondary);
let label = text!( let label = text!(
"{amount_reviewed} / {total}", "{amount_reviewed} / {total} ({percent:.0}%)",
amount_reviewed = changelog.len() amount_reviewed = changelog.len()
) )
.font(Font::MONOSPACE) .font(Font::MONOSPACE)
@ -326,7 +324,8 @@ impl Generator {
"Type a changelog entry title...", "Type a changelog entry title...",
title, title,
) )
.on_input(Message::TitleChanged); .on_input(Message::TitleChanged)
.on_submit(Message::Next);
let category = pick_list( let category = pick_list(
changelog::Category::ALL, changelog::Category::ALL,