WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Library/Homebrew/download_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,21 @@ def message_with_progress(downloadable, future, message)

max_phase_length = 11
phase = format("%-<phase>#{max_phase_length}s", phase: downloadable.phase.to_s.capitalize)
progress = " [#{phase} #{formatted_fetched_size}/#{formatted_total_size}]"
progress_bar = if future.fulfilled? || downloadable.phase != :downloading
""
else
percent = if (total_size = downloadable.total_size)
(fetched_size.to_f / [1, total_size].max).clamp(0.0, 1.0)
else
0.0
end
bar_length = [4, available_width / 5].max
bar_used = (percent * bar_length).round
bar_completed = "━" * bar_used
bar_pending = "┈" * (bar_length - bar_used)
"#{bar_completed}#{bar_pending} "
Comment on lines +307 to +309
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bar_completed = "" * bar_used
bar_pending = "" * (bar_length - bar_used)
"#{bar_completed}#{bar_pending} "
bar_completed = "=" * bar_used
bar_pending = " " * (bar_length - bar_used)
"[#{bar_completed}#{bar_pending}] "

and perhaps adding a => somewhere makes it more closely resemble curl --progress-bar which I think looks a little nicer. Could you rework to take that approach?

end
progress = " #{progress_bar}#{phase} #{formatted_fetched_size}/#{formatted_total_size}"
message_length = available_width - progress.length
return message[0, available_width].to_s unless message_length.positive?

Expand Down
Loading