Class: WritersRoom::Commands::Report

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

Instance Method Summary collapse

Instance Method Details

#reportObject



10
11
12
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
44
45
46
47
48
# File 'lib/writers_room/cli/report.rb', line 10

def report
  require_relative "../producer"

  producer = WritersRoom::Producer.new
  report_data = producer.generate_report

  if report_data[:total_scenes].zero?
    say "No transcripts found in transcripts/ directory", :yellow
    say "Run 'wr produce' or 'wr direct' to create transcripts", :yellow
    exit 0
  end

  say "=" * 60, :cyan
  say "PRODUCTION REPORT", :cyan
  say "=" * 60, :cyan
  say "Total scenes: #{report_data[:total_scenes]}", :white
  say "Total lines: #{report_data[:total_lines]}", :white
  say ""
  say "Lines by character:", :white

  report_data[:lines_by_character].sort_by { |_, count| -count }.each do |char, count|
    percentage = (count.to_f / report_data[:total_lines] * 100).round(1)
    say "  #{char}: #{count} (#{percentage}%)", :white
  end

  say ""
  say "Transcripts:", :white
  report_data[:transcripts].each do |transcript|
    say "  #{transcript}", :white
  end
  say "=" * 60, :cyan
rescue WritersRoom::Error => e
  say "Error: #{e.message}", :red
  exit 1
rescue StandardError => e
  say "Error generating report: #{e.message}", :red
  say e.backtrace.join("\n"), :red if ENV["DEBUG"]
  exit 1
end