Method: Fast.report

Defined in:
lib/fast/cli.rb

.report(result, show_link: false, show_permalink: false, show_sexp: false, file: nil, headless: false, bodyless: false, colorize: true) ⇒ Object

Combines highlight with files printing file name in the head with the source line.

Examples:

Fast.report(result, file: 'file.rb')

Parameters:

  • result (Astrolabe::Node)
  • show_sexp (Boolean) (defaults to: false)

    Show string expression instead of source

  • file (String) (defaults to: nil)

    Show the file name and result line before content

  • headless (Boolean) (defaults to: false)

    Skip printing the file name and line before content



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fast/cli.rb', line 68

def report(result, show_link: false, show_permalink: false, show_sexp: false, file: nil, headless: false, bodyless: false, colorize: true) # rubocop:disable Metrics/ParameterLists
  if file
    line = result.loc.expression.line if result.is_a?(Parser::AST::Node)
    if show_link
      puts(result.link)
    elsif show_permalink
      puts(result.permalink)
    elsif !headless
      puts(highlight("# #{file}:#{line}", colorize: colorize))
    end
  end
  puts(highlight(result, show_sexp: show_sexp, colorize: colorize)) unless bodyless
end