Method: Transpec::CLI#run

Defined in:
lib/transpec/cli.rb

#run(args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/transpec/cli.rb', line 31

def run(args)
  non_option_args = parse_options(args)

  fail_if_should_not_continue!

  paths = non_option_args

  if paths.empty?
    if Dir.exists?('spec')
      paths = ['spec']
    else
      fail ArgumentError, 'Specify target files or directories.'
    end
  end

  target_files(paths).each do |file_path|
    puts "Processing #{file_path}"
    rewriter = Rewriter.new(@configuration)
    rewriter.rewrite_file!(file_path)
  end

  # TODO: Print summary

  true
rescue => error
  warn error.message
  false
end