Skip to content

Commit bfd79ff

Browse files
napoleondclaude
andcommitted
feat(email): add --unread-only flag for inbox and search commands
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1431205 commit bfd79ff

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

packages/atxp/src/commands/email.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface EmailOptions {
1010
subject?: string;
1111
body?: string;
1212
attach?: string[];
13+
unreadOnly?: boolean;
1314
}
1415

1516
interface Attachment {
@@ -77,6 +78,9 @@ function showEmailHelp(): void {
7778
console.log(' ' + chalk.cyan('npx atxp email claim-username') + ' ' + chalk.yellow('<name>') + ' ' + 'Claim a username ($1.00)');
7879
console.log(' ' + chalk.cyan('npx atxp email release-username') + ' ' + 'Release your username');
7980
console.log();
81+
console.log(chalk.bold('Inbox/Search Options:'));
82+
console.log(' ' + chalk.yellow('--unread-only') + ' ' + 'Only show unread messages');
83+
console.log();
8084
console.log(chalk.bold('Send/Reply Options:'));
8185
console.log(' ' + chalk.yellow('--to') + ' ' + chalk.gray('<email>') + ' ' + 'Recipient email address (required for send)');
8286
console.log(' ' + chalk.yellow('--subject') + ' ' + chalk.gray('<text>') + ' ' + 'Email subject line (required for send)');
@@ -89,6 +93,7 @@ function showEmailHelp(): void {
8993
console.log();
9094
console.log(chalk.bold('Examples:'));
9195
console.log(' npx atxp email inbox');
96+
console.log(' npx atxp email inbox --unread-only');
9297
console.log(' npx atxp email read msg_abc123');
9398
console.log(' npx atxp email send --to user@example.com --subject "Hello" --body "Hi there!"');
9499
console.log(' npx atxp email send --to user@example.com --subject "Report" --body "See attached." --attach report.pdf');
@@ -125,7 +130,7 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
125130

126131
switch (subCommand) {
127132
case 'inbox':
128-
await checkInbox();
133+
await checkInbox(options.unreadOnly);
129134
break;
130135

131136
case 'read':
@@ -141,7 +146,7 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
141146
break;
142147

143148
case 'search':
144-
await searchEmails(messageId);
149+
await searchEmails(messageId, options.unreadOnly);
145150
break;
146151

147152
case 'delete':
@@ -168,8 +173,10 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
168173
}
169174
}
170175

171-
async function checkInbox(): Promise<void> {
172-
const result = await callTool(SERVER, 'email_check_inbox', {});
176+
async function checkInbox(unreadOnly?: boolean): Promise<void> {
177+
const args: Record<string, unknown> = {};
178+
if (unreadOnly) args.unreadOnly = true;
179+
const result = await callTool(SERVER, 'email_check_inbox', args);
173180

174181
try {
175182
const parsed = JSON.parse(result);
@@ -373,14 +380,16 @@ async function replyToEmail(messageId?: string, options?: EmailOptions): Promise
373380
}
374381
}
375382

376-
async function searchEmails(query?: string): Promise<void> {
383+
async function searchEmails(query?: string, unreadOnly?: boolean): Promise<void> {
377384
if (!query) {
378385
console.error(chalk.red('Error: search query is required'));
379386
console.log(`Usage: ${chalk.cyan('npx atxp email search <query>')}`);
380387
process.exit(1);
381388
}
382389

383-
const result = await callTool(SERVER, 'email_search', { query });
390+
const args: Record<string, unknown> = { query };
391+
if (unreadOnly) args.unreadOnly = true;
392+
const result = await callTool(SERVER, 'email_search', args);
384393

385394
try {
386395
const parsed = JSON.parse(result);

packages/atxp/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ interface EmailOptions {
4949
subject?: string;
5050
body?: string;
5151
attach?: string[];
52+
unreadOnly?: boolean;
5253
}
5354

5455
interface PhoneOptionsLocal {
@@ -271,6 +272,7 @@ function parseArgs(): {
271272
subject: getArgValue('--subject', ''),
272273
body: getArgValue('--body', ''),
273274
attach: getAllArgValues('--attach'),
275+
unreadOnly: process.argv.includes('--unread-only'),
274276
};
275277

276278
// Parse phone options

0 commit comments

Comments
 (0)