Class: Ocak::Commands::Issue::View

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/ocak/commands/issue/view.rb

Instance Method Summary collapse

Instance Method Details

#call(issue:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ocak/commands/issue/view.rb', line 14

def call(issue:, **)
  config = Config.load
  fetcher = LocalIssueFetcher.new(config: config)
  data = fetcher.view(issue.to_i)

  unless data
    warn "Issue ##{issue} not found."
    exit 1
  end

  labels = (data['labels'] || []).map { |l| l['name'] }.join(', ')
  puts "##{data['number']}  #{data['title']}"
  puts "Labels: #{labels}" unless labels.empty?
  puts "Complexity: #{data['complexity']}" if data['complexity'] && data['complexity'] != 'full'
  puts ''
  puts data['body'] unless data['body'].to_s.empty?

  # Show pipeline comments from the raw file
  path = File.join('.ocak', 'issues', format('%04d.md', issue.to_i))
  show_pipeline_comments(path)
rescue Config::ConfigNotFound => e
  warn "Error: #{e.message}"
  exit 1
end