Class: Ocak::Commands::Issue::Create

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

Instance Method Summary collapse

Instance Method Details

#call(title:, **options) ⇒ Object



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

def call(title:, **options)
  config = Config.load
  fetcher = LocalIssueFetcher.new(config: config)

  body = options[:body]
  body = read_from_editor(title) if body.empty?

  number = fetcher.create(
    title: title,
    body: body,
    labels: options[:label],
    complexity: options[:complexity]
  )

  path = File.join('.ocak', 'issues', format('%04d.md', number))
  puts "Created issue ##{number} (#{path})"
rescue Config::ConfigNotFound => e
  warn "Error: #{e.message}"
  exit 1
end