Class: Reviewer::Runner::Guidance

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/runner/guidance.rb

Overview

Handles the logic around what to display after a command has been run

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command:, result:, context:) ⇒ Guidance

Create an instance of guidance for suggesting recovery steps after errors



16
17
18
19
20
21
# File 'lib/reviewer/runner/guidance.rb', line 16

def initialize(command:, result:, context:)
  @command = command
  @result = result
  @context = context
  @formatter = Runner::Formatter.new(context.output)
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/reviewer/runner/guidance.rb', line 7

def command
  @command
end

#formatterObject (readonly)

Returns the value of attribute formatter.



7
8
9
# File 'lib/reviewer/runner/guidance.rb', line 7

def formatter
  @formatter
end

#resultObject (readonly)

Returns the value of attribute result.



7
8
9
# File 'lib/reviewer/runner/guidance.rb', line 7

def result
  @result
end

Instance Method Details

#showvoid

This method returns an undefined value.

Prints the relevant guidance based on the command and result context



26
27
28
29
30
31
32
# File 'lib/reviewer/runner/guidance.rb', line 26

def show
  case result
  when executable_not_found? then show_missing_executable_guidance
  when cannot_execute?       then show_unrecoverable_guidance
  else                            show_syntax_guidance
  end
end