Module: Linear::Commands::AddComment

Extended by:
AddComment
Included in:
Linear::Commands, AddComment
Defined in:
lib/linear/commands/add_comment.rb

Instance Method Summary collapse

Instance Method Details

#add_comment(issue_id, body, client: Client.new) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/linear/commands/add_comment.rb', line 6

def add_comment(issue_id, body, client: Client.new)
  # First get the issue to get its internal ID
  issue_result = client.query(Queries::ISSUE, { id: issue_id })
  issue = issue_result.dig("data", "issue")

  unless issue
    puts "Error: Issue not found: #{issue_id}"
    return
  end

  result = client.query(Queries::CREATE_COMMENT, {
    issueId: issue['id'],
    body: body
  })

  if result.dig("data", "commentCreate", "success")
    puts "Comment added to #{issue_id}"
  else
    puts "Error: Failed to add comment"
  end
end