Class: MitchAI::CLI
- Inherits:
-
Thor
- Object
- Thor
- MitchAI::CLI
- Defined in:
- lib/mitch_ai/cli.rb
Instance Method Summary collapse
-
#review(path) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity.
Instance Method Details
#review(path) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
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 44 45 46 47 48 49 50 |
# File 'lib/mitch_ai/cli.rb', line 17 def review(path) # Validate API key is configured ensure_api_key_configured # Determine if path is file or directory paths = if File.directory?(path) Dir.glob("#{path}/**/*").select { |f| File.file?(f) } else [path] end results = paths.map do |file_path| spinner = TTY::Spinner.new("[:spinner] Analyzing #{file_path}...", format: :dots) spinner.auto_spin analyzer = Analyzers::FileAnalyzer.new(file_path) result = analyzer.analyze spinner.success('✅ Done') result rescue StandardError => e puts "❌ Error: #{e.}" nil end.compact puts "\nFound #{results.length} files to analyze\n\n" # Output results output_results(results, [:format]) rescue StandardError => e # Stop the spinner with error message if there's an exception spinner.error('(Error!)') if defined?(spinner) && spinner puts "Error during analysis: #{e.class}: #{e.}" puts e.backtrace[0..5] if [:verbose] nil end |