Class: Suma::Cli::Reformat

Inherits:
Thor
  • Object
show all
Defined in:
lib/suma/cli/reformat.rb

Overview

Reformat command for reformatting EXPRESS files

Instance Method Summary collapse

Instance Method Details

#reformat(express_file_path) ⇒ Object

rubocop:disable Metrics/AbcSize



16
17
18
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/suma/cli/reformat.rb', line 16

def reformat(express_file_path) # rubocop:disable Metrics/AbcSize
  if File.file?(express_file_path)
    unless File.exist?(express_file_path)
      raise Errno::ENOENT, "Specified EXPRESS file " \
                           "`#{express_file_path}` not found."
    end

    if File.extname(express_file_path) != ".exp"
      raise ArgumentError, "Specified file `#{express_file_path}` is " \
                           "not an EXPRESS file."
    end

    exp_files = [express_file_path]
  elsif options[:recursive]
    exp_files = Dir.glob("#{express_file_path}/**/*.exp")
  else
    exp_files = Dir.glob("#{express_file_path}/*.exp")
  end

  if exp_files.empty?
    raise Errno::ENOENT, "No EXPRESS files found in " \
                         "`#{express_file_path}`."
  end

  run(exp_files)
end