class Spoom::Cli::Run
Constants
- DEFAULT_FORMAT
- SORT_CODE
- SORT_ENUM
- SORT_LOC
Public Instance Methods
colorize_message(message)
click to toggle source
# File lib/spoom/cli/run.rb, line 92 def colorize_message(message) return message unless color? cyan = T.let(false, T::Boolean) word = StringIO.new message.chars.each do |c| if c == '`' cyan = !cyan next end word << (cyan ? c.cyan : c.red) end word.string end
format_error(error, format)
click to toggle source
# File lib/spoom/cli/run.rb, line 83 def format_error(error, format) line = format line = line.gsub(/%C/, yellow(error.code.to_s)) line = line.gsub(/%F/, error.file) line = line.gsub(/%L/, error.line.to_s) line = line.gsub(/%M/, colorize_message(error.message)) line end
tc(*arg)
click to toggle source
# File lib/spoom/cli/run.rb, line 25 def tc(*arg) in_sorbet_project! path = exec_path limit = options[:limit] sort = options[:sort] code = options[:code] uniq = options[:uniq] format = options[:format] count = options[:count] sorbet = options[:sorbet] unless limit || code || sort output, status = T.unsafe(Spoom::Sorbet).srb_tc(*arg, path: path, capture_err: false, sorbet_bin: sorbet) say_error(output, status: nil, nl: false) exit(status) end output, status = T.unsafe(Spoom::Sorbet).srb_tc(*arg, path: path, capture_err: true, sorbet_bin: sorbet) if status say_error(output, status: nil, nl: false) exit(0) end errors = Spoom::Sorbet::Errors::Parser.parse_string(output) errors_count = errors.size errors = case sort when SORT_CODE Spoom::Sorbet::Errors.sort_errors_by_code(errors) when SORT_LOC errors.sort else errors # preserve natural sort end errors = errors.select { |e| e.code == code } if code errors = T.must(errors.slice(0, limit)) if limit lines = errors.map { |e| format_error(e, format || DEFAULT_FORMAT) } lines = lines.uniq if uniq lines.each do |line| say_error(line, status: nil) end if count if errors_count == errors.size say_error("Errors: #{errors_count}", status: nil) else say_error("Errors: #{errors.size} shown, #{errors_count} total", status: nil) end end exit(1) end