Class: Foxtail::CLI::Commands::Check

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/foxtail/cli/commands/check.rb

Overview

Check FTL files for syntax errors

Instance Method Summary collapse

Instance Method Details

#call(files:, quiet:) ⇒ void

This method returns an undefined value.

Execute the check command

Parameters:

  • files (Array<String>)

    FTL files to check

  • quiet (Boolean)

    Only show errors, no summary

Raises:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/foxtail/cli/commands/check.rb', line 19

def call(files:, quiet:, **)
  raise Foxtail::CLI::NoFilesError if files.empty?

  total_errors = 0
  total_files = 0

  files.each do |file|
    errors = check_file(file)
    total_files += 1
    total_errors += errors.size

    errors.each do |error|
      err.puts error
    end
  end

  unless quiet
    out.puts
    out.puts "#{total_files} file(s) checked, #{total_errors} error(s) found"
  end

  raise Foxtail::CLI::CheckError, total_errors if total_errors > 0
end