/lib/rails_best_practices/command.rb

http://github.com/flyerhzm/rails_best_practices · Ruby · 17 lines · 14 code · 2 blank · 1 comment · 3 complexity · aceea916a0a2e360f11ed59a24d11ff4 MD5 · raw file

  1. # frozen_string_literal: true
  2. require 'optparse'
  3. options = RailsBestPractices::OptionParser.parse!
  4. if !ARGV.empty? && !File.exist?(ARGV.first)
  5. puts "#{ARGV.first} doesn't exist"
  6. exit 1
  7. end
  8. if options['generate']
  9. RailsBestPractices::Analyzer.new(ARGV.first).generate
  10. else
  11. analyzer = RailsBestPractices::Analyzer.new(ARGV.first, options)
  12. analyzer.analyze
  13. analyzer.output
  14. exit !analyzer.runner.errors.empty? ? 1 : 0
  15. end