/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
- # frozen_string_literal: true
- require 'optparse'
- options = RailsBestPractices::OptionParser.parse!
- if !ARGV.empty? && !File.exist?(ARGV.first)
- puts "#{ARGV.first} doesn't exist"
- exit 1
- end
- if options['generate']
- RailsBestPractices::Analyzer.new(ARGV.first).generate
- else
- analyzer = RailsBestPractices::Analyzer.new(ARGV.first, options)
- analyzer.analyze
- analyzer.output
- exit !analyzer.runner.errors.empty? ? 1 : 0
- end