Class: Foxtail::CLI::Commands::Tidy
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Foxtail::CLI::Commands::Tidy
- Defined in:
- lib/foxtail/cli/commands/tidy.rb
Overview
Format FTL files with consistent style
Instance Method Summary collapse
-
#call(files:, write:, check:, diff:, with_junk:) ⇒ void
Execute the tidy command.
Instance Method Details
#call(files:, write:, check:, diff:, with_junk:) ⇒ void
This method returns an undefined value.
Execute the tidy command
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/foxtail/cli/commands/tidy.rb', line 25 def call(files:, write:, check:, diff:, with_junk:, **) raise Foxtail::CLI::NoFilesError if files.empty? files_with_errors = [] files_needing_format = [] multiple_files = files.size > 1 files.each do |file| result = process_file(file, write:, check:, diff:, with_junk:, multiple_files:) case result when :has_errors files_with_errors << file when :needs_format files_needing_format << file end end raise Foxtail::CLI::TidyError, files_with_errors unless files_with_errors.empty? raise Foxtail::CLI::TidyCheckError, files_needing_format if check && !files_needing_format.empty? end |