Class: Ocak::Commands::Issue::Edit

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

Instance Method Summary collapse

Instance Method Details

#call(issue:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ocak/commands/issue/edit.rb', line 13

def call(issue:, **)
  config = Config.load
  path = File.join(config.project_dir, '.ocak', 'issues', format('%04d.md', issue.to_i))

  unless File.exist?(path)
    warn "Issue ##{issue} not found at #{path}"
    exit 1
  end

  editor = ENV.fetch('EDITOR', 'vi')
  system(editor, path)
rescue Config::ConfigNotFound => e
  warn "Error: #{e.message}"
  exit 1
end