dooray-mail-cli 0.2.1 → 0.2.3
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/dooray-cli.js +56 -12
- package/package.json +1 -1
package/dooray-cli.js
CHANGED
|
@@ -69,10 +69,10 @@ async function handleCommand() {
|
|
|
69
69
|
await configCommand();
|
|
70
70
|
break;
|
|
71
71
|
case 'list':
|
|
72
|
-
await listCommand();
|
|
72
|
+
await listCommand(args.slice(1));
|
|
73
73
|
break;
|
|
74
74
|
case 'recent':
|
|
75
|
-
await recentCommand();
|
|
75
|
+
await recentCommand(args.slice(1));
|
|
76
76
|
break;
|
|
77
77
|
case 'read':
|
|
78
78
|
await readCommand(args[1]);
|
|
@@ -152,19 +152,22 @@ async function configCommand() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// list: 읽지 않은 메일 목록
|
|
155
|
-
async function listCommand() {
|
|
155
|
+
async function listCommand(args) {
|
|
156
|
+
// 첫 번째 인자로 개수 지정 가능
|
|
157
|
+
const limit = args && args[0] && !isNaN(args[0]) ? parseInt(args[0]) : 1000;
|
|
158
|
+
|
|
156
159
|
const config = loadConfig();
|
|
157
160
|
const client = await createClient(config);
|
|
158
161
|
|
|
159
162
|
try {
|
|
160
|
-
const mails = await client.getUnreadMail(
|
|
163
|
+
const mails = await client.getUnreadMail(limit);
|
|
161
164
|
|
|
162
165
|
if (mails.length === 0) {
|
|
163
166
|
console.log('📭 No unread mails');
|
|
164
167
|
return;
|
|
165
168
|
}
|
|
166
169
|
|
|
167
|
-
console.log(`\n📬 Unread Mails (${mails.length})\n`);
|
|
170
|
+
console.log(`\n📬 Unread Mails (${mails.length}${limit < 1000 ? ` / showing ${limit}` : ''})\n`);
|
|
168
171
|
mails.forEach((mail, idx) => {
|
|
169
172
|
const fromText = typeof mail.from === 'object' ? `${mail.from.name} <${mail.from.email}>` : mail.from;
|
|
170
173
|
console.log(`${idx + 1}. [UID: ${mail.id}] ${fromText}`);
|
|
@@ -177,25 +180,58 @@ async function listCommand() {
|
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
// recent: 최근 메일 목록 (읽음/안읽음 모두)
|
|
180
|
-
async function recentCommand() {
|
|
183
|
+
async function recentCommand(args) {
|
|
184
|
+
// 옵션 파싱
|
|
185
|
+
let limit = 1000;
|
|
186
|
+
let since, before;
|
|
187
|
+
|
|
188
|
+
if (args) {
|
|
189
|
+
for (let i = 0; i < args.length; i++) {
|
|
190
|
+
if (args[i] === '--since' && args[i + 1]) {
|
|
191
|
+
since = args[++i];
|
|
192
|
+
} else if (args[i] === '--before' && args[i + 1]) {
|
|
193
|
+
before = args[++i];
|
|
194
|
+
} else if (!isNaN(args[i])) {
|
|
195
|
+
limit = parseInt(args[i]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
181
200
|
const config = loadConfig();
|
|
182
201
|
const client = await createClient(config);
|
|
183
202
|
|
|
184
203
|
try {
|
|
185
|
-
|
|
204
|
+
let mails;
|
|
205
|
+
|
|
206
|
+
// 날짜 필터가 있으면 searchMail 사용
|
|
207
|
+
if (since || before) {
|
|
208
|
+
mails = await client.searchMail([], { since, before });
|
|
209
|
+
// limit 적용
|
|
210
|
+
if (mails.length > limit) {
|
|
211
|
+
mails = mails.slice(0, limit);
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
// 날짜 필터 없으면 기존 getRecentMail 사용
|
|
215
|
+
mails = await client.getRecentMail(limit);
|
|
216
|
+
}
|
|
186
217
|
|
|
187
218
|
if (mails.length === 0) {
|
|
188
219
|
console.log('📭 No mails found');
|
|
189
220
|
return;
|
|
190
221
|
}
|
|
191
222
|
|
|
192
|
-
|
|
223
|
+
const filters = [];
|
|
224
|
+
if (since) filters.push(`since: ${since}`);
|
|
225
|
+
if (before) filters.push(`before: ${before}`);
|
|
226
|
+
const filterStr = filters.length > 0 ? ` (${filters.join(', ')})` : '';
|
|
227
|
+
|
|
228
|
+
console.log(`\n📬 Recent Mails${filterStr} (${mails.length}${limit < 1000 ? ` / showing ${limit}` : ''})\n`);
|
|
193
229
|
mails.forEach((mail, idx) => {
|
|
194
230
|
const readStatus = mail.isRead ? '✓' : '●';
|
|
195
231
|
const fromText = typeof mail.from === 'object' ? `${mail.from.name} <${mail.from.email}>` : mail.from;
|
|
196
|
-
console.log(`${idx + 1}. ${readStatus} [UID: ${mail.id}] ${fromText}`);
|
|
232
|
+
console.log(`${idx + 1}. ${readStatus} [UID: ${mail.id || mail.uid}] ${fromText}`);
|
|
197
233
|
console.log(` Subject: ${mail.subject}`);
|
|
198
|
-
console.log(` Date: ${mail.receivedAt}\n`);
|
|
234
|
+
console.log(` Date: ${mail.receivedAt || mail.date}\n`);
|
|
199
235
|
});
|
|
200
236
|
} finally {
|
|
201
237
|
await client.close();
|
|
@@ -804,8 +840,12 @@ Usage: dooray-cli <command> [options]
|
|
|
804
840
|
|
|
805
841
|
Commands:
|
|
806
842
|
config Set up email configuration
|
|
807
|
-
list
|
|
808
|
-
|
|
843
|
+
list [count] List unread mails (default: 1000)
|
|
844
|
+
list 50 Show 50 unread mails
|
|
845
|
+
recent [count] List recent mails (default: 1000)
|
|
846
|
+
recent 100 Show 100 recent mails
|
|
847
|
+
recent --since <YYYY-MM-DD> --before <YYYY-MM-DD>
|
|
848
|
+
Filter by date range
|
|
809
849
|
read <uid> Read a specific mail by UID
|
|
810
850
|
send Send a new mail (interactive)
|
|
811
851
|
send --to <email> --subject <subject> --body <body>
|
|
@@ -846,7 +886,11 @@ Commands:
|
|
|
846
886
|
Examples:
|
|
847
887
|
dooray-cli config
|
|
848
888
|
dooray-cli list
|
|
889
|
+
dooray-cli list 50
|
|
849
890
|
dooray-cli recent
|
|
891
|
+
dooray-cli recent 100
|
|
892
|
+
dooray-cli recent --since "2026-01-01" --before "2026-02-01"
|
|
893
|
+
dooray-cli recent 50 --since "2026-02-01"
|
|
850
894
|
dooray-cli read 123
|
|
851
895
|
dooray-cli send --to "user@example.com" --subject "Hello" --body "Test"
|
|
852
896
|
dooray-cli send --to "user@example.com" --subject "Hello" --body "Test" --cc "cc@example.com" --attach "./file.pdf"
|