Class: Testprune::UI::ErrorToggle

Inherits:
Object
  • Object
show all
Defined in:
lib/testprune/ui/error_toggle.rb

Overview

Post-scan interactive prompt. When test errors occurred (non-blocking), shows a count indicator and lets the user toggle the error detail on/off before continuing the workflow.

Instance Method Summary collapse

Constructor Details

#initialize(errors:, io: $stderr, stdin: $stdin) ⇒ ErrorToggle

Returns a new instance of ErrorToggle.



11
12
13
14
15
16
# File 'lib/testprune/ui/error_toggle.rb', line 11

def initialize(errors:, io: $stderr, stdin: $stdin)
  @errors   = errors
  @io       = io
  @stdin    = stdin
  @expanded = false
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/testprune/ui/error_toggle.rb', line 18

def run
  return if @errors.empty?

  print_indicator
  loop do
    @io.print("  [e + Enter] #{styled('[e]', Styles::PURPLE_TEXT)} show/hide errors" \
              "  [Enter] skip > ")
    @io.flush
    input = @stdin.gets&.strip&.downcase
    break if input.nil? || input.empty?
    if input == 'e'
      @expanded = !@expanded
      @expanded ? print_errors : clear_errors
    end
  end
end