Class: RailsArchitect::CLI
- Inherits:
-
Thor
- Object
- Thor
- RailsArchitect::CLI
- Defined in:
- lib/rails_architect/cli.rb
Overview
Command-line interface for Rails Architect analysis tool
Instance Method Summary collapse
Instance Method Details
#analyze(project_path = nil) ⇒ Object
13 14 15 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 42 43 |
# File 'lib/rails_architect/cli.rb', line 13 def analyze(project_path = nil) project_path ||= Dir.pwd unless File.directory?(project_path) puts "❌ Project path does not exist: #{project_path}".colorize(:red) exit 1 end results = RailsArchitect::Core.new(project_path).analyze if [:json] output = RailsArchitect::Reporters::ReportGenerator.new(results).to_json if [:output] File.write([:output], output) puts "✅ JSON report saved to: #{[:output]}".colorize(:light_green) else puts output end elsif [:output] File.open([:output], "w") do |f| # Redirect output to file original_stdout = $stdout $stdout = f RailsArchitect::Reporters::ReportGenerator.new(results).generate $stdout = original_stdout end puts "✅ Report saved to: #{[:output]}".colorize(:light_green) else RailsArchitect::Reporters::ReportGenerator.new(results).generate end end |
#suggest(project_path = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rails_architect/cli.rb', line 46 def suggest(project_path = nil) project_path ||= Dir.pwd unless File.directory?(project_path) puts "❌ Project path does not exist: #{project_path}".colorize(:red) exit 1 end results = RailsArchitect::Core.new(project_path).analyze puts "\n#{'=' * 80}" puts "🎯 ARCHITECTURE SUGGESTIONS".colorize(:blue).bold puts "#{'=' * 80}\n" suggestions = ( results[:architecture][:suggestions] + results[:tdd][:suggestions] + results[:bdd][:suggestions] + results[:solid][:suggestions] ).uniq if suggestions.any? suggestions.each_with_index do |suggestion, index| puts "#{index + 1}. #{suggestion}" end else puts "✅ Your project is well-structured!".colorize(:light_green) end puts "\n#{'=' * 80}\n" end |
#version ⇒ Object
79 80 81 |
# File 'lib/rails_architect/cli.rb', line 79 def version puts "Rails Architect #{RailsArchitect::VERSION}" end |