6
7
8
9
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/linear/commands/create_issue.rb', line 6
def create_issue(options, client: Client.new)
teams_result = client.query(Queries::TEAMS)
teams = teams_result.dig("data", "teams", "nodes") || []
team = teams.find { |t| t['key'].upcase == options[:team].upcase }
unless team
puts "Error: Team '#{options[:team]}' not found. Available teams:"
teams.each { |t| puts " #{t['key']} - #{t['name']}" }
return
end
variables = {
teamId: team['id'],
title: options[:title]
}
variables[:description] = options[:description] if options[:description]
variables[:projectId] = options[:project] if options[:project]
if options[:priority]
variables[:priority] = options[:priority].to_i
end
if options[:state]
states_result = client.query(Queries::WORKFLOW_STATES, { teamId: team['id'] })
states = states_result.dig("data", "team", "states", "nodes") || []
target_state = states.find { |s| s['name'].downcase == options[:state].downcase }
if target_state
variables[:stateId] = target_state['id']
else
puts "Warning: State '#{options[:state]}' not found, using default"
end
end
if options[:assignee]
puts "Warning: Assignee lookup not yet implemented"
end
result = client.query(Queries::CREATE_ISSUE, variables)
if result.dig("data", "issueCreate", "success")
issue = result.dig("data", "issueCreate", "issue")
puts "Created issue: #{issue['identifier']}"
puts "Title: #{issue['title']}"
puts "URL: #{issue['url']}"
else
puts "Error: Failed to create issue"
end
end
|