Improve output.
This commit is contained in:
		
							parent
							
								
									0b50f0651e
								
							
						
					
					
						commit
						d6ebb04ff5
					
				| @ -82,12 +82,16 @@ module Homebrew | |||||||
| 
 | 
 | ||||||
|       class Spinner |       class Spinner | ||||||
|         FRAMES = [ |         FRAMES = [ | ||||||
|           "◜", |           "⠋", | ||||||
|           "◠", |           "⠙", | ||||||
|           "◝", |           "⠚", | ||||||
|           "◞", |           "⠞", | ||||||
|           "◡", |           "⠖", | ||||||
|           "◟", |           "⠦", | ||||||
|  |           "⠴", | ||||||
|  |           "⠲", | ||||||
|  |           "⠳", | ||||||
|  |           "⠓", | ||||||
|         ].freeze |         ].freeze | ||||||
| 
 | 
 | ||||||
|         sig { void } |         sig { void } | ||||||
| @ -221,22 +225,20 @@ module Homebrew | |||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         if concurrency == 1 |         if concurrency == 1 | ||||||
|           downloads.each_value do |promise| |           downloads.each do |downloadable, promise| | ||||||
|             promise.wait! |             promise.wait! | ||||||
|           rescue ChecksumMismatchError => e |           rescue ChecksumMismatchError => e | ||||||
|             opoo "#{downloadable.download_type.capitalize} reports different checksum: #{e.expected}" |             opoo "#{downloadable.download_type.capitalize} reports different checksum: #{e.expected}" | ||||||
|             Homebrew.failed = true if downloadable.is_a?(Resource::Patch) |             Homebrew.failed = true if downloadable.is_a?(Resource::Patch) | ||||||
|           end |           end | ||||||
|         else |         else | ||||||
| 
 |  | ||||||
|           spinner = Spinner.new |           spinner = Spinner.new | ||||||
| 
 |  | ||||||
|           remaining_downloads = downloads.dup |           remaining_downloads = downloads.dup | ||||||
| 
 |  | ||||||
|           previous_pending_line_count = 0 |           previous_pending_line_count = 0 | ||||||
| 
 | 
 | ||||||
|           begin |           begin | ||||||
|             print Tty.hide_cursor |             $stdout.print Tty.hide_cursor | ||||||
|  |             $stdout.flush | ||||||
| 
 | 
 | ||||||
|             output_message = lambda do |downloadable, promise| |             output_message = lambda do |downloadable, promise| | ||||||
|               status = case promise.state |               status = case promise.state | ||||||
| @ -245,13 +247,14 @@ module Homebrew | |||||||
|               when :rejected |               when :rejected | ||||||
|                 "#{Tty.red}✘#{Tty.reset}" |                 "#{Tty.red}✘#{Tty.reset}" | ||||||
|               when :pending |               when :pending | ||||||
|                 spinner |                 "#{Tty.blue}#{spinner}#{Tty.reset}" | ||||||
|               else |               else | ||||||
|                 raise promise.state |                 raise promise.state | ||||||
|               end |               end | ||||||
| 
 | 
 | ||||||
|               message = "#{downloadable.download_type.capitalize} #{downloadable.name}" |               message = "#{downloadable.download_type.capitalize} #{downloadable.name}" | ||||||
|               puts "#{status} #{message}" |               $stdout.puts "#{status} #{message}" | ||||||
|  |               $stdout.flush | ||||||
| 
 | 
 | ||||||
|               if promise.rejected? && (e = promise.reason).is_a?(ChecksumMismatchError) |               if promise.rejected? && (e = promise.reason).is_a?(ChecksumMismatchError) | ||||||
|                 opoo "#{downloadable.download_type.capitalize} reports different checksum: #{e.expected}" |                 opoo "#{downloadable.download_type.capitalize} reports different checksum: #{e.expected}" | ||||||
| @ -273,6 +276,7 @@ module Homebrew | |||||||
|                 finished_downloads.each do |downloadable, promise| |                 finished_downloads.each do |downloadable, promise| | ||||||
|                   previous_pending_line_count -= 1 |                   previous_pending_line_count -= 1 | ||||||
|                   print "\033[K" |                   print "\033[K" | ||||||
|  |                   $stdout.flush | ||||||
|                   output_message.call(downloadable, promise) |                   output_message.call(downloadable, promise) | ||||||
|                 end |                 end | ||||||
| 
 | 
 | ||||||
| @ -281,6 +285,7 @@ module Homebrew | |||||||
|                   break if previous_pending_line_count >= [concurrency, (Tty.height - 1)].min |                   break if previous_pending_line_count >= [concurrency, (Tty.height - 1)].min | ||||||
| 
 | 
 | ||||||
|                   print "\033[K" |                   print "\033[K" | ||||||
|  |                   $stdout.flush | ||||||
|                   previous_pending_line_count += output_message.call(downloadable, promise) |                   previous_pending_line_count += output_message.call(downloadable, promise) | ||||||
|                 end |                 end | ||||||
| 
 | 
 | ||||||
| @ -292,11 +297,13 @@ module Homebrew | |||||||
|                 sleep 0.05 |                 sleep 0.05 | ||||||
|               rescue Interrupt |               rescue Interrupt | ||||||
|                 print "\n" * previous_pending_line_count |                 print "\n" * previous_pending_line_count | ||||||
|  |                 $stdout.flush | ||||||
|                 raise |                 raise | ||||||
|               end |               end | ||||||
|             end |             end | ||||||
|           ensure |           ensure | ||||||
|             print Tty.show_cursor |             $stdout.print Tty.show_cursor | ||||||
|  |             $stdout.flush | ||||||
|           end |           end | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Markus Reiter
						Markus Reiter