Print --recent events as we seek

Amolith created

--recent seeks from newest events to oldest, so printing as we seek instead of
batching and printing in reverse changes this flag's message ordering to mirror
seek ordering: newest to oldest.

Change summary

bin/view-events | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

Detailed changes

bin/view-events 🔗

@@ -172,7 +172,6 @@ count = 0
 
 if options[:recent]
 	target = options[:recent]
-	matched = []
 	cursor = options[:end] ? to_stream_id(options[:end]) : "+"
 
 	loop do
@@ -181,19 +180,17 @@ if options[:recent]
 
 		entries.each do |_id, fields|
 			if matches?(fields, filters)
-				matched.unshift(fields)
-				break if matched.length >= target
+				puts format_event(fields, **options)
+				count += 1
+				break if count >= target
 			end
 		end
 
-		break if matched.length >= target
+		break if count >= target
 		cursor = prev_stream_id(entries.last[0])
 		break unless cursor
 		break if entries.size < BATCH_SIZE
 	end
-
-	matched.each { |fields| puts format_event(fields, **options) }
-	count = matched.length
 else
 	start_id = to_stream_id(options[:start])
 	end_id = options[:end] ? to_stream_id(options[:end]) : "+"