From e978ce5d896adede6472c94eb2f8ae8d6b27139a Mon Sep 17 00:00:00 2001 From: Devin Alexander Date: Fri, 13 Mar 2026 09:35:27 +0200 Subject: [PATCH 1/3] fix: show copy-pasteable command in pagination hint --- src/commands/broadcasts/list.ts | 2 +- src/commands/contact-properties/list.ts | 2 +- src/commands/contacts/list.ts | 2 +- src/commands/domains/list.ts | 2 +- src/commands/emails/list.ts | 2 +- src/commands/emails/receiving/attachments.ts | 2 +- src/commands/emails/receiving/list.ts | 2 +- src/commands/segments/list.ts | 2 +- src/commands/webhooks/list.ts | 2 +- src/lib/pagination.ts | 13 ++++++++----- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/commands/broadcasts/list.ts b/src/commands/broadcasts/list.ts index a823b0c..7252944 100644 --- a/src/commands/broadcasts/list.ts +++ b/src/commands/broadcasts/list.ts @@ -52,7 +52,7 @@ To retrieve full details (html, from, subject), use: resend broadcasts get ` sdkCall: (resend) => resend.broadcasts.list(paginationOpts), onInteractive: (list) => { console.log(renderBroadcastsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'broadcasts list'); }, }, globalOpts, diff --git a/src/commands/contact-properties/list.ts b/src/commands/contact-properties/list.ts index eccd819..238eaee 100644 --- a/src/commands/contact-properties/list.ts +++ b/src/commands/contact-properties/list.ts @@ -60,7 +60,7 @@ export const listContactPropertiesCommand = new Command('list') sdkCall: (resend) => resend.contactProperties.list(paginationOpts), onInteractive: (list) => { console.log(renderContactPropertiesTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'contact-properties list'); }, }, globalOpts, diff --git a/src/commands/contacts/list.ts b/src/commands/contacts/list.ts index 5fdb50f..ab246ef 100644 --- a/src/commands/contacts/list.ts +++ b/src/commands/contacts/list.ts @@ -49,7 +49,7 @@ Pagination: use --after or --before with a contact ID as the cursor. sdkCall: (resend) => resend.contacts.list(paginationOpts), onInteractive: (list) => { console.log(renderContactsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'contacts list'); }, }, globalOpts, diff --git a/src/commands/domains/list.ts b/src/commands/domains/list.ts index 3448772..c7159c8 100644 --- a/src/commands/domains/list.ts +++ b/src/commands/domains/list.ts @@ -45,7 +45,7 @@ export const listDomainsCommand = new Command('list') sdkCall: (resend) => resend.domains.list(paginationOpts), onInteractive: (list) => { console.log(renderDomainsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'domains list'); }, }, globalOpts, diff --git a/src/commands/emails/list.ts b/src/commands/emails/list.ts index 57353a1..6e0d24b 100644 --- a/src/commands/emails/list.ts +++ b/src/commands/emails/list.ts @@ -76,7 +76,7 @@ export const listEmailsCommand = new Command('list') sdkCall: (resend) => resend.emails.list(paginationOpts), onInteractive: (list) => { console.log(renderSentEmailsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'emails list'); }, }, globalOpts, diff --git a/src/commands/emails/receiving/attachments.ts b/src/commands/emails/receiving/attachments.ts index ed2d578..adbbd58 100644 --- a/src/commands/emails/receiving/attachments.ts +++ b/src/commands/emails/receiving/attachments.ts @@ -60,7 +60,7 @@ export const listAttachmentsCommand = new Command('attachments') }), onInteractive: (list) => { console.log(renderAttachmentsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, `emails receiving attachments ${emailId}`); }, }, globalOpts, diff --git a/src/commands/emails/receiving/list.ts b/src/commands/emails/receiving/list.ts index 614fedc..73c0433 100644 --- a/src/commands/emails/receiving/list.ts +++ b/src/commands/emails/receiving/list.ts @@ -51,7 +51,7 @@ export const listReceivingCommand = new Command('list') sdkCall: (resend) => resend.emails.receiving.list(paginationOpts), onInteractive: (list) => { console.log(renderReceivingEmailsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'emails receiving list'); }, }, globalOpts, diff --git a/src/commands/segments/list.ts b/src/commands/segments/list.ts index 24546cd..745ee01 100644 --- a/src/commands/segments/list.ts +++ b/src/commands/segments/list.ts @@ -50,7 +50,7 @@ or "resend contacts add-segment".`, sdkCall: (resend) => resend.segments.list(paginationOpts), onInteractive: (list) => { console.log(renderSegmentsTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'segments list'); }, }, globalOpts, diff --git a/src/commands/webhooks/list.ts b/src/commands/webhooks/list.ts index fce5ff7..4cc54f0 100644 --- a/src/commands/webhooks/list.ts +++ b/src/commands/webhooks/list.ts @@ -47,7 +47,7 @@ The response includes has_more: true when additional pages exist.`, sdkCall: (resend) => resend.webhooks.list(paginationOpts), onInteractive: (list) => { console.log(renderWebhooksTable(list.data)); - printPaginationHint(list); + printPaginationHint(list, 'webhooks list'); }, }, globalOpts, diff --git a/src/lib/pagination.ts b/src/lib/pagination.ts index f74a0d0..a71c840 100644 --- a/src/lib/pagination.ts +++ b/src/lib/pagination.ts @@ -23,14 +23,17 @@ export function buildPaginationOpts( return after ? { limit, after } : before ? { limit, before } : { limit }; } -export function printPaginationHint(list: { - has_more: boolean; - data: Array<{ id: string }>; -}): void { +export function printPaginationHint( + list: { + has_more: boolean; + data: Array<{ id: string }>; + }, + command: string, +): void { if (list.has_more && list.data.length > 0) { const last = list.data[list.data.length - 1]; console.log( - `\nMore results available. Use --after ${last.id} to fetch the next page.`, + `\nFetch the next page:\n$ resend ${command} --after ${last.id}`, ); } } From 032432350feca922a5601c3c8672807dafc5c565 Mon Sep 17 00:00:00 2001 From: Devin Alexander Date: Fri, 13 Mar 2026 09:41:48 +0200 Subject: [PATCH 2/3] fix: preserve --limit flag in pagination hint --- src/commands/broadcasts/list.ts | 2 +- src/commands/contact-properties/list.ts | 2 +- src/commands/contacts/list.ts | 2 +- src/commands/domains/list.ts | 2 +- src/commands/emails/list.ts | 2 +- src/commands/emails/receiving/attachments.ts | 6 +++++- src/commands/emails/receiving/list.ts | 2 +- src/commands/segments/list.ts | 2 +- src/commands/webhooks/list.ts | 2 +- src/lib/pagination.ts | 4 +++- 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/commands/broadcasts/list.ts b/src/commands/broadcasts/list.ts index 7252944..eee6f6b 100644 --- a/src/commands/broadcasts/list.ts +++ b/src/commands/broadcasts/list.ts @@ -52,7 +52,7 @@ To retrieve full details (html, from, subject), use: resend broadcasts get ` sdkCall: (resend) => resend.broadcasts.list(paginationOpts), onInteractive: (list) => { console.log(renderBroadcastsTable(list.data)); - printPaginationHint(list, 'broadcasts list'); + printPaginationHint(list, 'broadcasts list', limit); }, }, globalOpts, diff --git a/src/commands/contact-properties/list.ts b/src/commands/contact-properties/list.ts index 238eaee..46d75ac 100644 --- a/src/commands/contact-properties/list.ts +++ b/src/commands/contact-properties/list.ts @@ -60,7 +60,7 @@ export const listContactPropertiesCommand = new Command('list') sdkCall: (resend) => resend.contactProperties.list(paginationOpts), onInteractive: (list) => { console.log(renderContactPropertiesTable(list.data)); - printPaginationHint(list, 'contact-properties list'); + printPaginationHint(list, 'contact-properties list', limit); }, }, globalOpts, diff --git a/src/commands/contacts/list.ts b/src/commands/contacts/list.ts index ab246ef..d96e4d6 100644 --- a/src/commands/contacts/list.ts +++ b/src/commands/contacts/list.ts @@ -49,7 +49,7 @@ Pagination: use --after or --before with a contact ID as the cursor. sdkCall: (resend) => resend.contacts.list(paginationOpts), onInteractive: (list) => { console.log(renderContactsTable(list.data)); - printPaginationHint(list, 'contacts list'); + printPaginationHint(list, 'contacts list', limit); }, }, globalOpts, diff --git a/src/commands/domains/list.ts b/src/commands/domains/list.ts index c7159c8..27a26e7 100644 --- a/src/commands/domains/list.ts +++ b/src/commands/domains/list.ts @@ -45,7 +45,7 @@ export const listDomainsCommand = new Command('list') sdkCall: (resend) => resend.domains.list(paginationOpts), onInteractive: (list) => { console.log(renderDomainsTable(list.data)); - printPaginationHint(list, 'domains list'); + printPaginationHint(list, 'domains list', limit); }, }, globalOpts, diff --git a/src/commands/emails/list.ts b/src/commands/emails/list.ts index 6e0d24b..28a1212 100644 --- a/src/commands/emails/list.ts +++ b/src/commands/emails/list.ts @@ -76,7 +76,7 @@ export const listEmailsCommand = new Command('list') sdkCall: (resend) => resend.emails.list(paginationOpts), onInteractive: (list) => { console.log(renderSentEmailsTable(list.data)); - printPaginationHint(list, 'emails list'); + printPaginationHint(list, 'emails list', limit); }, }, globalOpts, diff --git a/src/commands/emails/receiving/attachments.ts b/src/commands/emails/receiving/attachments.ts index adbbd58..0265b6b 100644 --- a/src/commands/emails/receiving/attachments.ts +++ b/src/commands/emails/receiving/attachments.ts @@ -60,7 +60,11 @@ export const listAttachmentsCommand = new Command('attachments') }), onInteractive: (list) => { console.log(renderAttachmentsTable(list.data)); - printPaginationHint(list, `emails receiving attachments ${emailId}`); + printPaginationHint( + list, + `emails receiving attachments ${emailId}`, + limit, + ); }, }, globalOpts, diff --git a/src/commands/emails/receiving/list.ts b/src/commands/emails/receiving/list.ts index 73c0433..d0025dc 100644 --- a/src/commands/emails/receiving/list.ts +++ b/src/commands/emails/receiving/list.ts @@ -51,7 +51,7 @@ export const listReceivingCommand = new Command('list') sdkCall: (resend) => resend.emails.receiving.list(paginationOpts), onInteractive: (list) => { console.log(renderReceivingEmailsTable(list.data)); - printPaginationHint(list, 'emails receiving list'); + printPaginationHint(list, 'emails receiving list', limit); }, }, globalOpts, diff --git a/src/commands/segments/list.ts b/src/commands/segments/list.ts index 745ee01..4b270b3 100644 --- a/src/commands/segments/list.ts +++ b/src/commands/segments/list.ts @@ -50,7 +50,7 @@ or "resend contacts add-segment".`, sdkCall: (resend) => resend.segments.list(paginationOpts), onInteractive: (list) => { console.log(renderSegmentsTable(list.data)); - printPaginationHint(list, 'segments list'); + printPaginationHint(list, 'segments list', limit); }, }, globalOpts, diff --git a/src/commands/webhooks/list.ts b/src/commands/webhooks/list.ts index 4cc54f0..471d6d1 100644 --- a/src/commands/webhooks/list.ts +++ b/src/commands/webhooks/list.ts @@ -47,7 +47,7 @@ The response includes has_more: true when additional pages exist.`, sdkCall: (resend) => resend.webhooks.list(paginationOpts), onInteractive: (list) => { console.log(renderWebhooksTable(list.data)); - printPaginationHint(list, 'webhooks list'); + printPaginationHint(list, 'webhooks list', limit); }, }, globalOpts, diff --git a/src/lib/pagination.ts b/src/lib/pagination.ts index a71c840..177684f 100644 --- a/src/lib/pagination.ts +++ b/src/lib/pagination.ts @@ -29,11 +29,13 @@ export function printPaginationHint( data: Array<{ id: string }>; }, command: string, + limit?: number, ): void { if (list.has_more && list.data.length > 0) { const last = list.data[list.data.length - 1]; + const limitFlag = limit ? ` --limit ${limit}` : ''; console.log( - `\nFetch the next page:\n$ resend ${command} --after ${last.id}`, + `\nFetch the next page:\n$ resend ${command} --after ${last.id}${limitFlag}`, ); } } From 4689100ec432ec03d264ac7046bc6175ca16f829 Mon Sep 17 00:00:00 2001 From: Devin Alexander Date: Fri, 13 Mar 2026 09:50:38 +0200 Subject: [PATCH 3/3] fix: respect --before direction in pagination hint --- src/commands/broadcasts/list.ts | 5 ++++- src/commands/contact-properties/list.ts | 5 ++++- src/commands/contacts/list.ts | 5 ++++- src/commands/domains/list.ts | 5 ++++- src/commands/emails/list.ts | 5 ++++- src/commands/emails/receiving/attachments.ts | 7 +++---- src/commands/emails/receiving/list.ts | 5 ++++- src/commands/segments/list.ts | 5 ++++- src/commands/webhooks/list.ts | 5 ++++- src/lib/pagination.ts | 21 +++++++++++++------- 10 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/commands/broadcasts/list.ts b/src/commands/broadcasts/list.ts index eee6f6b..a92a52d 100644 --- a/src/commands/broadcasts/list.ts +++ b/src/commands/broadcasts/list.ts @@ -52,7 +52,10 @@ To retrieve full details (html, from, subject), use: resend broadcasts get ` sdkCall: (resend) => resend.broadcasts.list(paginationOpts), onInteractive: (list) => { console.log(renderBroadcastsTable(list.data)); - printPaginationHint(list, 'broadcasts list', limit); + printPaginationHint(list, 'broadcasts list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/contact-properties/list.ts b/src/commands/contact-properties/list.ts index 46d75ac..eb8c058 100644 --- a/src/commands/contact-properties/list.ts +++ b/src/commands/contact-properties/list.ts @@ -60,7 +60,10 @@ export const listContactPropertiesCommand = new Command('list') sdkCall: (resend) => resend.contactProperties.list(paginationOpts), onInteractive: (list) => { console.log(renderContactPropertiesTable(list.data)); - printPaginationHint(list, 'contact-properties list', limit); + printPaginationHint(list, 'contact-properties list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/contacts/list.ts b/src/commands/contacts/list.ts index d96e4d6..a1953aa 100644 --- a/src/commands/contacts/list.ts +++ b/src/commands/contacts/list.ts @@ -49,7 +49,10 @@ Pagination: use --after or --before with a contact ID as the cursor. sdkCall: (resend) => resend.contacts.list(paginationOpts), onInteractive: (list) => { console.log(renderContactsTable(list.data)); - printPaginationHint(list, 'contacts list', limit); + printPaginationHint(list, 'contacts list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/domains/list.ts b/src/commands/domains/list.ts index 27a26e7..3444541 100644 --- a/src/commands/domains/list.ts +++ b/src/commands/domains/list.ts @@ -45,7 +45,10 @@ export const listDomainsCommand = new Command('list') sdkCall: (resend) => resend.domains.list(paginationOpts), onInteractive: (list) => { console.log(renderDomainsTable(list.data)); - printPaginationHint(list, 'domains list', limit); + printPaginationHint(list, 'domains list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/emails/list.ts b/src/commands/emails/list.ts index 28a1212..2521b0f 100644 --- a/src/commands/emails/list.ts +++ b/src/commands/emails/list.ts @@ -76,7 +76,10 @@ export const listEmailsCommand = new Command('list') sdkCall: (resend) => resend.emails.list(paginationOpts), onInteractive: (list) => { console.log(renderSentEmailsTable(list.data)); - printPaginationHint(list, 'emails list', limit); + printPaginationHint(list, 'emails list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/emails/receiving/attachments.ts b/src/commands/emails/receiving/attachments.ts index 0265b6b..395e041 100644 --- a/src/commands/emails/receiving/attachments.ts +++ b/src/commands/emails/receiving/attachments.ts @@ -60,11 +60,10 @@ export const listAttachmentsCommand = new Command('attachments') }), onInteractive: (list) => { console.log(renderAttachmentsTable(list.data)); - printPaginationHint( - list, - `emails receiving attachments ${emailId}`, + printPaginationHint(list, `emails receiving attachments ${emailId}`, { limit, - ); + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/emails/receiving/list.ts b/src/commands/emails/receiving/list.ts index d0025dc..08b2f35 100644 --- a/src/commands/emails/receiving/list.ts +++ b/src/commands/emails/receiving/list.ts @@ -51,7 +51,10 @@ export const listReceivingCommand = new Command('list') sdkCall: (resend) => resend.emails.receiving.list(paginationOpts), onInteractive: (list) => { console.log(renderReceivingEmailsTable(list.data)); - printPaginationHint(list, 'emails receiving list', limit); + printPaginationHint(list, 'emails receiving list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/segments/list.ts b/src/commands/segments/list.ts index 4b270b3..c8402a9 100644 --- a/src/commands/segments/list.ts +++ b/src/commands/segments/list.ts @@ -50,7 +50,10 @@ or "resend contacts add-segment".`, sdkCall: (resend) => resend.segments.list(paginationOpts), onInteractive: (list) => { console.log(renderSegmentsTable(list.data)); - printPaginationHint(list, 'segments list', limit); + printPaginationHint(list, 'segments list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/commands/webhooks/list.ts b/src/commands/webhooks/list.ts index 471d6d1..1a9a34c 100644 --- a/src/commands/webhooks/list.ts +++ b/src/commands/webhooks/list.ts @@ -47,7 +47,10 @@ The response includes has_more: true when additional pages exist.`, sdkCall: (resend) => resend.webhooks.list(paginationOpts), onInteractive: (list) => { console.log(renderWebhooksTable(list.data)); - printPaginationHint(list, 'webhooks list', limit); + printPaginationHint(list, 'webhooks list', { + limit, + before: opts.before, + }); }, }, globalOpts, diff --git a/src/lib/pagination.ts b/src/lib/pagination.ts index 177684f..a8b832c 100644 --- a/src/lib/pagination.ts +++ b/src/lib/pagination.ts @@ -29,13 +29,20 @@ export function printPaginationHint( data: Array<{ id: string }>; }, command: string, - limit?: number, + opts: { limit?: number; before?: string }, ): void { - if (list.has_more && list.data.length > 0) { - const last = list.data[list.data.length - 1]; - const limitFlag = limit ? ` --limit ${limit}` : ''; - console.log( - `\nFetch the next page:\n$ resend ${command} --after ${last.id}${limitFlag}`, - ); + if (!list.has_more || list.data.length === 0) { + return; } + + const backward = Boolean(opts.before); + const cursor = backward + ? list.data[0].id + : list.data[list.data.length - 1].id; + const flag = backward ? '--before' : '--after'; + const limitFlag = opts.limit ? ` --limit ${opts.limit}` : ''; + + console.log( + `\nFetch the next page:\n$ resend ${command} ${flag} ${cursor}${limitFlag}`, + ); }