Class: RegoValidate::ErrorReporter::TextFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/cli/reporting.rb

Overview

Emits text error output for CLI.

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:) ⇒ TextFormatter

Returns a new instance of TextFormatter.

Parameters:

  • stdout (IO)
  • stderr (IO)


199
200
201
202
# File 'lib/ruby/rego/cli/reporting.rb', line 199

def initialize(stdout:, stderr:)
  @stdout = stdout
  @stderr = stderr
end

Instance Method Details

#error(message, parser = nil) ⇒ void

This method returns an undefined value.

Parameters:

  • message (String)
  • parser (OptionParser, nil) (defaults to: nil)


207
208
209
210
# File 'lib/ruby/rego/cli/reporting.rb', line 207

def error(message, parser = nil)
  stderr.puts("Error: #{message}")
  stderr.puts(parser) if parser
end

#rego_error(error) ⇒ void

This method returns an undefined value.

Parameters:



214
215
216
217
218
# File 'lib/ruby/rego/cli/reporting.rb', line 214

def rego_error(error)
  location = error.location
  stderr.puts("Error: #{error.message}")
  stderr.puts("  at #{location}") if location
end