1
2
3
4
5
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "lin", about = "A fast CLI for Linear", version)]
pub struct Cli {
/// Workspace to use (overrides config and .linear-workspace file)
#[arg(long, short, global = true)]
pub workspace: Option<String>,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Authenticate with Linear using an API token
Login {
/// Your Linear API token
token: String,
/// Workspace name to associate with this token
#[arg(long, default_value = "default")]
name: String,
},
/// Manage issues
#[command(subcommand)]
Issue(IssueCommand),
/// Manage workspaces
#[command(subcommand)]
Workspace(WorkspaceCommand),
/// Manage comments
#[command(subcommand)]
Comment(CommentCommand),
/// Manage projects
#[command(subcommand)]
Project(ProjectCommand),
/// List teams
#[command(subcommand)]
Team(TeamCommand),
/// List users
#[command(subcommand)]
User(UserCommand),
/// Manage labels
#[command(subcommand)]
Label(LabelCommand),
/// Manage cycles
#[command(subcommand)]
Cycle(CycleCommand),
/// Manage initiatives
#[command(subcommand)]
Initiative(InitiativeCommand),
/// View changelog
Changelog,
}
#[derive(Subcommand)]
pub enum IssueCommand {
/// View issue details
View {
/// Issue identifier (e.g., ENG-123) or UUID
id: String,
},
/// Create a new issue
Create {
/// Issue title
title: String,
/// Team name, key, or UUID
#[arg(long)]
team: String,
/// Issue description
#[arg(long)]
description: Option<String>,
/// Priority (0=None, 1=Urgent, 2=High, 3=Medium, 4=Low)
#[arg(long)]
priority: Option<i32>,
/// Assignee (name, email, "me", or UUID)
#[arg(long)]
assignee: Option<String>,
/// Project name or UUID
#[arg(long)]
project: Option<String>,
/// Label IDs (comma-separated)
#[arg(long, value_delimiter = ',')]
label_ids: Option<Vec<String>>,
/// Label names (repeatable, resolved to IDs)
#[arg(long = "label", value_delimiter = ',')]
labels: Option<Vec<String>>,
/// Parent issue ID or identifier (e.g., APP-123)
#[arg(long)]
parent: Option<String>,
/// Attach a file to the created issue
#[arg(long)]
attachment: Option<String>,
},
/// Edit an existing issue
Edit {
/// Issue identifier (e.g., ENG-123) or UUID
id: String,
/// New title
#[arg(long)]
title: Option<String>,
/// New description
#[arg(long)]
description: Option<String>,
/// Priority (0=None, 1=Urgent, 2=High, 3=Medium, 4=Low)
#[arg(long)]
priority: Option<i32>,
/// Assignee (name, email, "me", or UUID)
#[arg(long)]
assignee: Option<String>,
/// Workflow state name
#[arg(long)]
state: Option<String>,
/// Project name or UUID
#[arg(long)]
project: Option<String>,
/// Label IDs (comma-separated)
#[arg(long, value_delimiter = ',')]
label_ids: Option<Vec<String>>,
/// Label names to add (repeatable, resolved to IDs)
#[arg(long = "label", value_delimiter = ',')]
labels: Option<Vec<String>>,
/// Label names to remove (repeatable, resolved to IDs)
#[arg(long = "remove-label", value_delimiter = ',')]
remove_labels: Option<Vec<String>>,
/// Parent issue ID or identifier (e.g., APP-123)
#[arg(long)]
parent: Option<String>,
/// Attach a file to the issue
#[arg(long)]
attachment: Option<String>,
},
/// Search issues (requires a search term)
Search {
/// Search query
query: String,
/// Filter by project (name or UUID)
#[arg(long)]
project: Option<String>,
/// Filter by team (name, key, or UUID)
#[arg(long)]
team: Option<String>,
/// Filter by assignee (name, email, "me", or UUID)
#[arg(long)]
assignee: Option<String>,
/// Filter by status name
#[arg(long)]
status: Option<String>,
/// Max results
#[arg(long, default_value = "20")]
limit: i32,
},
/// List issues with filters (no text search)
List {
/// Filter by team (name, key, or UUID)
#[arg(long)]
team: Option<String>,
/// Filter by assignee (name, email, "me", or UUID)
#[arg(long)]
assignee: Option<String>,
/// Filter by status name
#[arg(long)]
status: Option<String>,
/// Filter by project (name or UUID)
#[arg(long)]
project: Option<String>,
/// Filter by priority (0=None, 1=Urgent, 2=High, 3=Medium, 4=Low)
#[arg(long)]
priority: Option<i32>,
/// Max results
#[arg(long, default_value = "20")]
limit: i32,
},
/// List issues assigned to you
Me {
/// Filter by status name
#[arg(long)]
status: Option<String>,
/// Max results
#[arg(long, default_value = "20")]
limit: i32,
},
/// View or change issue state
State {
/// Issue identifier (e.g., ENG-123) or UUID
id: String,
/// New state name (omit to show current state)
name: Option<String>,
/// List all available states for the issue's team
#[arg(long)]
list: bool,
},
/// List attachments on an issue
Attachments {
/// Issue identifier (e.g., ENG-123) or UUID
id: String,
},
}
#[derive(Subcommand)]
pub enum WorkspaceCommand {
/// Show current workspace
Current,
/// List all configured workspaces
List,
/// Set workspace for the current directory
Set {
/// Workspace name
name: String,
/// Set as global default workspace instead of directory-specific
#[arg(long)]
global: bool,
},
}
#[derive(Subcommand)]
pub enum CommentCommand {
/// View comments on an issue
View {
/// Issue identifier
id: String,
/// Show comment IDs
#[arg(long)]
show_ids: bool,
},
/// Add a comment to an issue
Add {
/// Issue identifier
id: String,
/// Comment body
body: String,
/// Attach a file (uploads and embeds markdown link in body)
#[arg(long)]
attachment: Option<String>,
},
/// Edit a comment
Edit {
/// Comment ID
id: String,
/// New comment body
body: String,
/// Attach a file (uploads and embeds markdown link in body)
#[arg(long)]
attachment: Option<String>,
},
}
#[derive(Subcommand)]
pub enum ProjectCommand {
/// List projects
List {
/// Include archived projects
#[arg(long)]
include_archived: bool,
/// Maximum number of results
#[arg(long, default_value = "50")]
limit: i32,
},
/// View project details
View {
/// Project name or UUID
id: String,
},
/// Create a new project
Create {
/// Project name
name: String,
/// Team names, keys, or UUIDs (comma-separated, at least one required)
#[arg(long, value_delimiter = ',')]
teams: Vec<String>,
/// Project description
#[arg(long)]
description: Option<String>,
},
/// Edit a project
Edit {
/// Project name or UUID
id: String,
/// New name
#[arg(long)]
name: Option<String>,
/// New description
#[arg(long)]
description: Option<String>,
/// New state (e.g., planned, started, paused, completed, canceled)
#[arg(long)]
state: Option<String>,
},
/// Manage project updates
#[command(subcommand)]
Update(ProjectUpdateCommand),
}
#[derive(Subcommand)]
pub enum ProjectUpdateCommand {
/// List project updates
List {
/// Project name or UUID
project: String,
},
/// Add a project update
Add {
/// Project name or UUID
project: String,
/// Update body
body: String,
/// Health status (onTrack, atRisk, offTrack)
#[arg(long)]
health: Option<String>,
},
/// Edit a project update
Edit {
/// Update ID
id: String,
/// New body
#[arg(long)]
body: String,
/// Health status (onTrack, atRisk, offTrack)
#[arg(long)]
health: Option<String>,
},
/// Delete a project update
Delete {
/// Update ID
id: String,
},
}
#[derive(Subcommand)]
pub enum TeamCommand {
/// List teams
List,
}
#[derive(Subcommand)]
pub enum UserCommand {
/// List users
List,
}
#[derive(Subcommand)]
pub enum LabelCommand {
/// List labels
List {
/// Filter by team (name, key, or UUID)
#[arg(long)]
team: Option<String>,
},
/// Create a label
Create {
/// Label name
name: String,
/// Team name, key, or UUID
#[arg(long)]
team: String,
/// Label color (hex, e.g., #ff0000)
#[arg(long)]
color: Option<String>,
/// Label description
#[arg(long)]
description: Option<String>,
/// Parent label ID
#[arg(long)]
parent_id: Option<String>,
},
}
#[derive(Subcommand)]
pub enum CycleCommand {
/// List cycles for a team
List {
/// Team name, key, or UUID
#[arg(long)]
team: String,
/// Max results
#[arg(long, default_value = "10")]
limit: i32,
},
/// Show the currently active cycle for a team
Active {
/// Team name, key, or UUID
#[arg(long)]
team: String,
},
}
#[derive(Subcommand)]
pub enum InitiativeCommand {
/// List initiatives
List {
/// Max results
#[arg(long, default_value = "50")]
limit: i32,
},
/// View initiative details
View {
/// Initiative ID
id: String,
},
}