Skip to content

Commit 6fe00cf

Browse files
fix: preserve origin filter flag change column from required to default
1 parent b6d394c commit 6fe00cf

4 files changed

Lines changed: 51 additions & 8 deletions

File tree

skills/resend-cli/references/suppressions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ Suppressions block future sends to an address. Each entry has an `origin`:
2222

2323
List suppressed addresses (default subcommand — `resend suppressions` alone runs it).
2424

25-
| Flag | Type | Required | Description |
26-
|------|------|----------|-------------|
27-
| `--limit <n>` | number | No | Max results, 1-100 (default 10) |
28-
| `--after <cursor>` | string | No | Forward pagination cursor |
29-
| `--before <cursor>` | string | No | Backward pagination cursor |
30-
| `--origin <origin>` | string | No | Filter: `bounce` \| `complaint` \| `manual` |
25+
| Flag | Type | Default | Description |
26+
|------|------|---------|-------------|
27+
| `--limit <n>` | number | 10 | Max results, 1-100 |
28+
| `--after <cursor>` | string | | Forward pagination cursor |
29+
| `--before <cursor>` | string | | Backward pagination cursor |
30+
| `--origin <origin>` | string | | Filter: `bounce` \| `complaint` \| `manual` |
3131

3232
**Alias:** `ls`
3333

src/commands/suppressions/list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const listSuppressionsCommand = new Command('list')
6767
before: opts.before,
6868
apiKey: globalOpts.apiKey,
6969
profile: globalOpts.profile,
70+
...(opts.origin && { extraFlags: `--origin ${opts.origin}` }),
7071
});
7172
},
7273
},

src/lib/pagination.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ export function printPaginationHint(
4545
data: Array<{ id: string }>;
4646
},
4747
command: string,
48-
opts: { limit?: number; before?: string; apiKey?: string; profile?: string },
48+
opts: {
49+
limit?: number;
50+
before?: string;
51+
apiKey?: string;
52+
profile?: string;
53+
extraFlags?: string;
54+
},
4955
): void {
5056
if (!list.has_more || list.data.length === 0) {
5157
return;
@@ -61,8 +67,9 @@ export function printPaginationHint(
6167
const limitFlag = opts.limit ? ` --limit ${opts.limit}` : '';
6268
const apiKeyFlag = opts.apiKey ? ` --api-key ${maskKey(opts.apiKey)}` : '';
6369
const profileFlag = opts.profile ? ` --profile ${opts.profile}` : '';
70+
const extraFlags = opts.extraFlags ? ` ${opts.extraFlags}` : '';
6471

6572
console.log(
66-
`\nFetch the next page:\n$ resend ${command} ${flag} ${cursor}${limitFlag}${apiKeyFlag}${profileFlag}`,
73+
`\nFetch the next page:\n$ resend ${command} ${flag} ${cursor}${limitFlag}${extraFlags}${apiKeyFlag}${profileFlag}`,
6774
);
6875
}

tests/commands/suppressions/list.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,41 @@ describe('suppressions list command', () => {
149149
expect(getFirstCallArgs()).toMatchObject({ after: 'cur' });
150150
});
151151

152+
it('preserves --origin in the next-page hint', async () => {
153+
mockList.mockResolvedValueOnce({
154+
data: {
155+
object: 'list',
156+
data: [
157+
{
158+
object: 'suppression',
159+
id: 'sup-1',
160+
email: 'spam@example.com',
161+
origin: 'bounce',
162+
source_id: 'evt-1',
163+
created_at: '2026-01-01T00:00:00.000Z',
164+
},
165+
],
166+
has_more: true,
167+
},
168+
error: null,
169+
});
170+
// Interactive mode: the pagination hint only prints when stdout is a TTY.
171+
Object.defineProperty(process.stdin, 'isTTY', { value: true, writable: true });
172+
Object.defineProperty(process.stdout, 'isTTY', { value: true, writable: true });
173+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
174+
175+
const { listSuppressionsCommand } = await import(
176+
'../../../src/commands/suppressions/list'
177+
);
178+
await listSuppressionsCommand.parseAsync(['--origin', 'bounce'], {
179+
from: 'user',
180+
});
181+
182+
const output = logSpy.mock.calls.map((c) => c[0]).join('\n');
183+
logSpy.mockRestore();
184+
expect(output).toContain('--origin bounce');
185+
});
186+
152187
it('errors with list_error when SDK returns an error', async () => {
153188
setNonInteractive();
154189
mockList.mockResolvedValueOnce(

0 commit comments

Comments
 (0)