@cli4ai/gmail 1.0.11 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/run.js ADDED
@@ -0,0 +1,260 @@
1
+ #!/usr/bin/env node
2
+ // Gmail CLI tool
3
+ import { cli, withErrorHandling } from '@cli4ai/lib';
4
+ import * as messages from './lib/messages.js';
5
+ import * as threads from './lib/threads.js';
6
+ import * as send from './lib/send.js';
7
+ import * as labels from './lib/labels.js';
8
+ import * as attachments from './lib/attachments.js';
9
+ import * as drafts from './lib/drafts.js';
10
+ const program = cli('gmail', '1.0.0', 'Gmail CLI tool');
11
+ // Global options
12
+ program
13
+ .option('--raw, -r', 'Full JSON output')
14
+ .option('--compact, -c', 'Compact one-line output')
15
+ .option('--body, -b', 'Include body in search results')
16
+ .option('--full, -f', 'Full body (no truncation)')
17
+ .option('--limit <n>', 'Override default limit', parseInt)
18
+ .option('--cc <email>', 'Add CC recipient (send/draft)')
19
+ .option('--bcc <email>', 'Add BCC recipient (send/draft)')
20
+ .option('--attach <path>', 'Add attachment (repeatable)', (val, prev) => {
21
+ const list = prev || [];
22
+ list.push(val);
23
+ return list;
24
+ });
25
+ // ═══════════════════════════════════════════════════════════════════════════
26
+ // MESSAGE COMMANDS
27
+ // ═══════════════════════════════════════════════════════════════════════════
28
+ program
29
+ .command('inbox')
30
+ .description('Recent inbox messages')
31
+ .argument('[limit]', 'Number of messages', '20')
32
+ .action(withErrorHandling(async (limit, options, cmd) => {
33
+ const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
34
+ await messages.inbox(flags);
35
+ }));
36
+ program
37
+ .command('unread')
38
+ .description('Unread messages only')
39
+ .argument('[limit]', 'Number of messages', '20')
40
+ .action(withErrorHandling(async (limit, options, cmd) => {
41
+ const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
42
+ await messages.unread(flags);
43
+ }));
44
+ program
45
+ .command('search <query>')
46
+ .description('Search with Gmail syntax')
47
+ .argument('[limit]', 'Number of results', '20')
48
+ .action(withErrorHandling(async (query, limit, options, cmd) => {
49
+ const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
50
+ await messages.search(query, flags);
51
+ }));
52
+ program
53
+ .command('read <id>')
54
+ .description('Read full message')
55
+ .action(withErrorHandling(async (id, options, cmd) => {
56
+ await messages.read(id, cmd.parent.opts());
57
+ }));
58
+ program
59
+ .command('archive <id>')
60
+ .description('Archive message (remove from inbox)')
61
+ .action(withErrorHandling(async (id, options, cmd) => {
62
+ await messages.archive(id, cmd.parent.opts());
63
+ }));
64
+ program
65
+ .command('trash <id>')
66
+ .description('Move to trash')
67
+ .action(withErrorHandling(async (id, options, cmd) => {
68
+ await messages.trash(id, cmd.parent.opts());
69
+ }));
70
+ program
71
+ .command('untrash <id>')
72
+ .description('Remove from trash')
73
+ .action(withErrorHandling(async (id, options, cmd) => {
74
+ await messages.untrash(id, cmd.parent.opts());
75
+ }));
76
+ program
77
+ .command('star <id>')
78
+ .description('Star message')
79
+ .action(withErrorHandling(async (id, options, cmd) => {
80
+ await messages.star(id, cmd.parent.opts());
81
+ }));
82
+ program
83
+ .command('unstar <id>')
84
+ .description('Unstar message')
85
+ .action(withErrorHandling(async (id, options, cmd) => {
86
+ await messages.unstar(id, cmd.parent.opts());
87
+ }));
88
+ program
89
+ .command('markread <id>')
90
+ .description('Mark as read')
91
+ .action(withErrorHandling(async (id, options, cmd) => {
92
+ await messages.markRead(id, cmd.parent.opts());
93
+ }));
94
+ program
95
+ .command('markunread <id>')
96
+ .description('Mark as unread')
97
+ .action(withErrorHandling(async (id, options, cmd) => {
98
+ await messages.markUnread(id, cmd.parent.opts());
99
+ }));
100
+ // ═══════════════════════════════════════════════════════════════════════════
101
+ // THREAD COMMANDS
102
+ // ═══════════════════════════════════════════════════════════════════════════
103
+ program
104
+ .command('thread <id>')
105
+ .description('Full conversation thread')
106
+ .action(withErrorHandling(async (id, options, cmd) => {
107
+ await threads.get(id, cmd.parent.opts());
108
+ }));
109
+ program
110
+ .command('threads')
111
+ .description('List recent threads')
112
+ .argument('[limit]', 'Number of threads', '20')
113
+ .argument('[query]', 'Search query')
114
+ .action(withErrorHandling(async (limit, query, options, cmd) => {
115
+ const flags = { ...cmd.parent.opts(), limit: parseInt(limit), query };
116
+ await threads.list(flags);
117
+ }));
118
+ // ═══════════════════════════════════════════════════════════════════════════
119
+ // SEND COMMANDS
120
+ // ═══════════════════════════════════════════════════════════════════════════
121
+ program
122
+ .command('send <to> <subject> <body>')
123
+ .description('Send new email')
124
+ .action(withErrorHandling(async (to, subject, body, options, cmd) => {
125
+ await send.send(to, subject, body, cmd.parent.opts());
126
+ }));
127
+ program
128
+ .command('reply <id> <body>')
129
+ .description('Reply to message')
130
+ .action(withErrorHandling(async (id, body, options, cmd) => {
131
+ await send.reply(id, body, cmd.parent.opts());
132
+ }));
133
+ program
134
+ .command('replyall <id> <body>')
135
+ .description('Reply all')
136
+ .action(withErrorHandling(async (id, body, options, cmd) => {
137
+ await send.replyAll(id, body, cmd.parent.opts());
138
+ }));
139
+ program
140
+ .command('forward <id> <to>')
141
+ .description('Forward message')
142
+ .argument('[body]', 'Additional message')
143
+ .action(withErrorHandling(async (id, to, body, options, cmd) => {
144
+ await send.forward(id, to, body, cmd.parent.opts());
145
+ }));
146
+ program
147
+ .command('draft <to> <subject> <body>')
148
+ .description('Create draft')
149
+ .action(withErrorHandling(async (to, subject, body, options, cmd) => {
150
+ await send.draft(to, subject, body, cmd.parent.opts());
151
+ }));
152
+ // ═══════════════════════════════════════════════════════════════════════════
153
+ // LABEL COMMANDS
154
+ // ═══════════════════════════════════════════════════════════════════════════
155
+ program
156
+ .command('labels')
157
+ .description('List all labels')
158
+ .action(withErrorHandling(async (options, cmd) => {
159
+ await labels.list(cmd.parent.opts());
160
+ }));
161
+ program
162
+ .command('label <id> <label>')
163
+ .description('Add label to message')
164
+ .action(withErrorHandling(async (id, label, options, cmd) => {
165
+ await labels.addToMessage(id, label, cmd.parent.opts());
166
+ }));
167
+ program
168
+ .command('unlabel <id> <label>')
169
+ .description('Remove label from message')
170
+ .action(withErrorHandling(async (id, label, options, cmd) => {
171
+ await labels.removeFromMessage(id, label, cmd.parent.opts());
172
+ }));
173
+ program
174
+ .command('label-info <label>')
175
+ .description('Get label details with counts')
176
+ .action(withErrorHandling(async (label, options, cmd) => {
177
+ await labels.get(label, cmd.parent.opts());
178
+ }));
179
+ program
180
+ .command('label-create <name>')
181
+ .description('Create new label')
182
+ .action(withErrorHandling(async (name, options, cmd) => {
183
+ await labels.create(name, cmd.parent.opts());
184
+ }));
185
+ program
186
+ .command('label-delete <name>')
187
+ .description('Delete label')
188
+ .action(withErrorHandling(async (name, options, cmd) => {
189
+ await labels.remove(name, cmd.parent.opts());
190
+ }));
191
+ // ═══════════════════════════════════════════════════════════════════════════
192
+ // ATTACHMENT COMMANDS
193
+ // ═══════════════════════════════════════════════════════════════════════════
194
+ program
195
+ .command('attachments <id>')
196
+ .description('List attachments in message')
197
+ .action(withErrorHandling(async (id, options, cmd) => {
198
+ await attachments.list(id, cmd.parent.opts());
199
+ }));
200
+ program
201
+ .command('download <id>')
202
+ .description('Download attachment')
203
+ .argument('[filename]', 'Specific attachment filename')
204
+ .argument('[out]', 'Output directory')
205
+ .action(withErrorHandling(async (id, filename, out, options, cmd) => {
206
+ await attachments.download(id, filename, out, cmd.parent.opts());
207
+ }));
208
+ program
209
+ .command('download-all <id>')
210
+ .description('Download all attachments')
211
+ .argument('[dir]', 'Output directory')
212
+ .action(withErrorHandling(async (id, dir, options, cmd) => {
213
+ await attachments.downloadAll(id, dir, cmd.parent.opts());
214
+ }));
215
+ // ═══════════════════════════════════════════════════════════════════════════
216
+ // DRAFT COMMANDS
217
+ // ═══════════════════════════════════════════════════════════════════════════
218
+ program
219
+ .command('drafts')
220
+ .description('List all drafts')
221
+ .action(withErrorHandling(async (options, cmd) => {
222
+ await drafts.list(cmd.parent.opts());
223
+ }));
224
+ program
225
+ .command('draft-get <id>')
226
+ .description('Get draft content')
227
+ .action(withErrorHandling(async (id, options, cmd) => {
228
+ await drafts.get(id, cmd.parent.opts());
229
+ }));
230
+ program
231
+ .command('draft-create <to> <subject> <body>')
232
+ .description('Create new draft')
233
+ .action(withErrorHandling(async (to, subject, body, options, cmd) => {
234
+ await drafts.create(to, subject, body, cmd.parent.opts());
235
+ }));
236
+ program
237
+ .command('draft-reply <msgId> <body>')
238
+ .description('Create draft reply to message')
239
+ .action(withErrorHandling(async (msgId, body, options, cmd) => {
240
+ await drafts.createReply(msgId, body, cmd.parent.opts());
241
+ }));
242
+ program
243
+ .command('draft-update <id> <to> <subject> <body>')
244
+ .description('Update existing draft')
245
+ .action(withErrorHandling(async (id, to, subject, body, options, cmd) => {
246
+ await drafts.update(id, to, subject, body, cmd.parent.opts());
247
+ }));
248
+ program
249
+ .command('draft-delete <id>')
250
+ .description('Delete draft')
251
+ .action(withErrorHandling(async (id, options, cmd) => {
252
+ await drafts.remove(id, cmd.parent.opts());
253
+ }));
254
+ program
255
+ .command('draft-send <id>')
256
+ .description('Send draft')
257
+ .action(withErrorHandling(async (id, options, cmd) => {
258
+ await drafts.send(id, cmd.parent.opts());
259
+ }));
260
+ program.parse();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cli4ai/gmail",
3
- "version": "1.0.11",
3
+ "version": "1.0.14",
4
4
  "description": "Gmail CLI tool for messages, threads, and drafts",
5
5
  "author": "cliforai",
6
- "license": "MIT",
7
- "main": "run.ts",
6
+ "license": "BUSL-1.1",
7
+ "main": "dist/run.js",
8
8
  "bin": {
9
- "gmail": "./run.ts"
9
+ "gmail": "./dist/run.js"
10
10
  },
11
11
  "type": "module",
12
12
  "keywords": [
@@ -28,18 +28,26 @@
28
28
  "url": "https://github.com/cliforai/packages/issues"
29
29
  },
30
30
  "dependencies": {
31
- "@cli4ai/lib": "^1.0.0",
31
+ "@cli4ai/lib": "^1.0.9",
32
32
  "googleapis": "^144.0.0",
33
33
  "google-auth-library": "^9.0.0",
34
34
  "commander": "^14.0.0"
35
35
  },
36
36
  "files": [
37
- "run.ts",
37
+ "dist",
38
38
  "cli4ai.json",
39
39
  "README.md",
40
40
  "LICENSE"
41
41
  ],
42
42
  "publishConfig": {
43
43
  "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "prepublishOnly": "npm run build"
48
+ },
49
+ "devDependencies": {
50
+ "typescript": "^5.0.0",
51
+ "@types/node": "^22.0.0"
44
52
  }
45
53
  }
package/run.ts DELETED
@@ -1,316 +0,0 @@
1
- #!/usr/bin/env npx tsx
2
- // Gmail CLI tool
3
-
4
- import { cli, withErrorHandling } from '@cli4ai/lib/cli.ts';
5
-
6
- const messages = require('./lib/messages');
7
- const threads = require('./lib/threads');
8
- const send = require('./lib/send');
9
- const labels = require('./lib/labels');
10
- const attachments = require('./lib/attachments');
11
- const drafts = require('./lib/drafts');
12
-
13
- interface Flags {
14
- raw?: boolean;
15
- compact?: boolean;
16
- body?: boolean;
17
- fullBody?: boolean;
18
- limit?: number;
19
- cc?: string;
20
- bcc?: string;
21
- attach?: string[];
22
- }
23
-
24
- const program = cli('gmail', '1.0.0', 'Gmail CLI tool');
25
-
26
- // Global options
27
- program
28
- .option('--raw, -r', 'Full JSON output')
29
- .option('--compact, -c', 'Compact one-line output')
30
- .option('--body, -b', 'Include body in search results')
31
- .option('--full, -f', 'Full body (no truncation)')
32
- .option('--limit <n>', 'Override default limit', parseInt)
33
- .option('--cc <email>', 'Add CC recipient (send/draft)')
34
- .option('--bcc <email>', 'Add BCC recipient (send/draft)')
35
- .option('--attach <path>', 'Add attachment (repeatable)', (val: string, prev: string[] | undefined) => {
36
- const list = prev || [];
37
- list.push(val);
38
- return list;
39
- });
40
-
41
- // ═══════════════════════════════════════════════════════════════════════════
42
- // MESSAGE COMMANDS
43
- // ═══════════════════════════════════════════════════════════════════════════
44
-
45
- program
46
- .command('inbox')
47
- .description('Recent inbox messages')
48
- .argument('[limit]', 'Number of messages', '20')
49
- .action(withErrorHandling(async (limit: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
50
- const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
51
- await messages.inbox(flags);
52
- }));
53
-
54
- program
55
- .command('unread')
56
- .description('Unread messages only')
57
- .argument('[limit]', 'Number of messages', '20')
58
- .action(withErrorHandling(async (limit: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
59
- const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
60
- await messages.unread(flags);
61
- }));
62
-
63
- program
64
- .command('search <query>')
65
- .description('Search with Gmail syntax')
66
- .argument('[limit]', 'Number of results', '20')
67
- .action(withErrorHandling(async (query: string, limit: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
68
- const flags = { ...cmd.parent.opts(), limit: parseInt(limit) };
69
- await messages.search(query, flags);
70
- }));
71
-
72
- program
73
- .command('read <id>')
74
- .description('Read full message')
75
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
76
- await messages.read(id, cmd.parent.opts());
77
- }));
78
-
79
- program
80
- .command('archive <id>')
81
- .description('Archive message (remove from inbox)')
82
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
83
- await messages.archive(id, cmd.parent.opts());
84
- }));
85
-
86
- program
87
- .command('trash <id>')
88
- .description('Move to trash')
89
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
90
- await messages.trash(id, cmd.parent.opts());
91
- }));
92
-
93
- program
94
- .command('untrash <id>')
95
- .description('Remove from trash')
96
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
97
- await messages.untrash(id, cmd.parent.opts());
98
- }));
99
-
100
- program
101
- .command('star <id>')
102
- .description('Star message')
103
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
104
- await messages.star(id, cmd.parent.opts());
105
- }));
106
-
107
- program
108
- .command('unstar <id>')
109
- .description('Unstar message')
110
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
111
- await messages.unstar(id, cmd.parent.opts());
112
- }));
113
-
114
- program
115
- .command('markread <id>')
116
- .description('Mark as read')
117
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
118
- await messages.markRead(id, cmd.parent.opts());
119
- }));
120
-
121
- program
122
- .command('markunread <id>')
123
- .description('Mark as unread')
124
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
125
- await messages.markUnread(id, cmd.parent.opts());
126
- }));
127
-
128
- // ═══════════════════════════════════════════════════════════════════════════
129
- // THREAD COMMANDS
130
- // ═══════════════════════════════════════════════════════════════════════════
131
-
132
- program
133
- .command('thread <id>')
134
- .description('Full conversation thread')
135
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
136
- await threads.get(id, cmd.parent.opts());
137
- }));
138
-
139
- program
140
- .command('threads')
141
- .description('List recent threads')
142
- .argument('[limit]', 'Number of threads', '20')
143
- .argument('[query]', 'Search query')
144
- .action(withErrorHandling(async (limit: string, query: string | undefined, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
145
- const flags = { ...cmd.parent.opts(), limit: parseInt(limit), query };
146
- await threads.list(flags);
147
- }));
148
-
149
- // ═══════════════════════════════════════════════════════════════════════════
150
- // SEND COMMANDS
151
- // ═══════════════════════════════════════════════════════════════════════════
152
-
153
- program
154
- .command('send <to> <subject> <body>')
155
- .description('Send new email')
156
- .action(withErrorHandling(async (to: string, subject: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
157
- await send.send(to, subject, body, cmd.parent.opts());
158
- }));
159
-
160
- program
161
- .command('reply <id> <body>')
162
- .description('Reply to message')
163
- .action(withErrorHandling(async (id: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
164
- await send.reply(id, body, cmd.parent.opts());
165
- }));
166
-
167
- program
168
- .command('replyall <id> <body>')
169
- .description('Reply all')
170
- .action(withErrorHandling(async (id: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
171
- await send.replyAll(id, body, cmd.parent.opts());
172
- }));
173
-
174
- program
175
- .command('forward <id> <to>')
176
- .description('Forward message')
177
- .argument('[body]', 'Additional message')
178
- .action(withErrorHandling(async (id: string, to: string, body: string | undefined, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
179
- await send.forward(id, to, body, cmd.parent.opts());
180
- }));
181
-
182
- program
183
- .command('draft <to> <subject> <body>')
184
- .description('Create draft')
185
- .action(withErrorHandling(async (to: string, subject: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
186
- await send.draft(to, subject, body, cmd.parent.opts());
187
- }));
188
-
189
- // ═══════════════════════════════════════════════════════════════════════════
190
- // LABEL COMMANDS
191
- // ═══════════════════════════════════════════════════════════════════════════
192
-
193
- program
194
- .command('labels')
195
- .description('List all labels')
196
- .action(withErrorHandling(async (options: Flags, cmd: { parent: { opts: () => Flags } }) => {
197
- await labels.list(cmd.parent.opts());
198
- }));
199
-
200
- program
201
- .command('label <id> <label>')
202
- .description('Add label to message')
203
- .action(withErrorHandling(async (id: string, label: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
204
- await labels.addToMessage(id, label, cmd.parent.opts());
205
- }));
206
-
207
- program
208
- .command('unlabel <id> <label>')
209
- .description('Remove label from message')
210
- .action(withErrorHandling(async (id: string, label: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
211
- await labels.removeFromMessage(id, label, cmd.parent.opts());
212
- }));
213
-
214
- program
215
- .command('label-info <label>')
216
- .description('Get label details with counts')
217
- .action(withErrorHandling(async (label: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
218
- await labels.get(label, cmd.parent.opts());
219
- }));
220
-
221
- program
222
- .command('label-create <name>')
223
- .description('Create new label')
224
- .action(withErrorHandling(async (name: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
225
- await labels.create(name, cmd.parent.opts());
226
- }));
227
-
228
- program
229
- .command('label-delete <name>')
230
- .description('Delete label')
231
- .action(withErrorHandling(async (name: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
232
- await labels.remove(name, cmd.parent.opts());
233
- }));
234
-
235
- // ═══════════════════════════════════════════════════════════════════════════
236
- // ATTACHMENT COMMANDS
237
- // ═══════════════════════════════════════════════════════════════════════════
238
-
239
- program
240
- .command('attachments <id>')
241
- .description('List attachments in message')
242
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
243
- await attachments.list(id, cmd.parent.opts());
244
- }));
245
-
246
- program
247
- .command('download <id>')
248
- .description('Download attachment')
249
- .argument('[filename]', 'Specific attachment filename')
250
- .argument('[out]', 'Output directory')
251
- .action(withErrorHandling(async (id: string, filename: string | undefined, out: string | undefined, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
252
- await attachments.download(id, filename, out, cmd.parent.opts());
253
- }));
254
-
255
- program
256
- .command('download-all <id>')
257
- .description('Download all attachments')
258
- .argument('[dir]', 'Output directory')
259
- .action(withErrorHandling(async (id: string, dir: string | undefined, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
260
- await attachments.downloadAll(id, dir, cmd.parent.opts());
261
- }));
262
-
263
- // ═══════════════════════════════════════════════════════════════════════════
264
- // DRAFT COMMANDS
265
- // ═══════════════════════════════════════════════════════════════════════════
266
-
267
- program
268
- .command('drafts')
269
- .description('List all drafts')
270
- .action(withErrorHandling(async (options: Flags, cmd: { parent: { opts: () => Flags } }) => {
271
- await drafts.list(cmd.parent.opts());
272
- }));
273
-
274
- program
275
- .command('draft-get <id>')
276
- .description('Get draft content')
277
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
278
- await drafts.get(id, cmd.parent.opts());
279
- }));
280
-
281
- program
282
- .command('draft-create <to> <subject> <body>')
283
- .description('Create new draft')
284
- .action(withErrorHandling(async (to: string, subject: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
285
- await drafts.create(to, subject, body, cmd.parent.opts());
286
- }));
287
-
288
- program
289
- .command('draft-reply <msgId> <body>')
290
- .description('Create draft reply to message')
291
- .action(withErrorHandling(async (msgId: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
292
- await drafts.createReply(msgId, body, cmd.parent.opts());
293
- }));
294
-
295
- program
296
- .command('draft-update <id> <to> <subject> <body>')
297
- .description('Update existing draft')
298
- .action(withErrorHandling(async (id: string, to: string, subject: string, body: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
299
- await drafts.update(id, to, subject, body, cmd.parent.opts());
300
- }));
301
-
302
- program
303
- .command('draft-delete <id>')
304
- .description('Delete draft')
305
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
306
- await drafts.remove(id, cmd.parent.opts());
307
- }));
308
-
309
- program
310
- .command('draft-send <id>')
311
- .description('Send draft')
312
- .action(withErrorHandling(async (id: string, options: Flags, cmd: { parent: { opts: () => Flags } }) => {
313
- await drafts.send(id, cmd.parent.opts());
314
- }));
315
-
316
- program.parse();