-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththread.ts
More file actions
54 lines (50 loc) · 2.29 KB
/
thread.ts
File metadata and controls
54 lines (50 loc) · 2.29 KB
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
import { Command, Option } from 'commander'
import { withUnvalidatedChoices } from '../lib/completion.js'
import { markThreadDone } from './thread/mutate.js'
import { replyToThread } from './thread/reply.js'
import { viewThread } from './thread/view.js'
export function registerThreadCommand(program: Command): void {
const thread = program.command('thread').description('Thread operations')
thread
.command('view [thread-ref]', { isDefault: true })
.description('Display a thread with its comments')
.option('--comment <id>', 'Show only a specific comment')
.option('--unread', 'Show only unread comments (with original post for context)')
.option('--context <n>', 'Include N read comments before unread (use with --unread)')
.option('--limit <n>', 'Max comments to show (default: 50)')
.option('--since <date>', 'Comments newer than')
.option('--until <date>', 'Comments older than')
.option('--raw', 'Show raw markdown instead of rendered')
.option('--json', 'Output as JSON')
.option('--ndjson', 'Output as newline-delimited JSON')
.option('--full', 'Include all fields in JSON output')
.action((ref, options) => {
if (!ref) {
thread.help()
return
}
return viewThread(ref, options)
})
thread
.command('reply <thread-ref> [content]')
.description('Post a comment to a thread')
.addOption(
withUnvalidatedChoices(
new Option(
'--notify <recipients>',
'Notification recipients: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user IDs (default: EVERYONE_IN_THREAD)',
),
['EVERYONE', 'EVERYONE_IN_THREAD'],
),
)
.option('--dry-run', 'Show what would be posted without posting')
.option('--json', 'Output posted comment as JSON')
.option('--full', 'Include all fields in JSON output')
.action(replyToThread)
thread
.command('done <thread-ref>')
.description('Archive a thread (mark as done)')
.option('--dry-run', 'Show what would happen without executing')
.option('--json', 'Output result as JSON')
.action(markThreadDone)
}