Class: XCAssetsCop::CLI

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

Instance Method Summary collapse

Instance Method Details

#lint(config_path = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/xcassetscop/cli.rb', line 10

def lint(config_path = nil)
  configfile_path = File.expand_path(config_path || './xcassetscop.yml')
  unless File.file? configfile_path
    puts "Can't find file on path: #{configfile_path}"
    return
  end
  puts "Using config file at #{configfile_path}"

  rules = ConfigfileParser.parse configfile_path
  amount_of_files = rules.reduce(0) { |acc, rule| rule.paths.size + acc }
  errors = Linter.lint_files rules

  puts "#{rules.size} rules found"
  puts "#{amount_of_files} files checked"
  if errors.size.positive?
    puts "Found #{errors.size} offenses:"
    puts errors
  else
    puts 'No errors found'
  end
end

#versionObject



33
34
35
# File 'lib/xcassetscop/cli.rb', line 33

def version
  puts Version.version
end