fix(cli): validate directory limits before resolution

This commit is contained in:
Peter Steinberger
2026-05-27 07:33:53 -04:00
parent 0889106cb2
commit 513a223c15
2 changed files with 6 additions and 2 deletions

View File

@@ -317,5 +317,7 @@ describe("registerDirectoryCli", () => {
await expect(program.parseAsync(args, { from: "user" })).rejects.toThrow("exit:1");
expect(runtimeErrors().join("\n")).toContain("--limit must be a positive integer.");
expect(mocks.resolveInstallableChannelPlugin).not.toHaveBeenCalled();
expect(mocks.replaceConfigFile).not.toHaveBeenCalled();
});
});

View File

@@ -155,6 +155,7 @@ export function registerDirectoryCli(program: Command) {
title: string;
emptyMessage: string;
}) => {
const limit = parseLimit(params.opts.limit);
const { cfg, channelId, accountId, plugin } = await resolve({
channel: params.opts.channel as string | undefined,
account: params.opts.account as string | undefined,
@@ -170,7 +171,7 @@ export function registerDirectoryCli(program: Command) {
cfg,
accountId,
query: (params.opts.query as string | undefined) ?? null,
limit: parseLimit(params.opts.limit),
limit,
runtime: defaultRuntime,
});
if (params.opts.json) {
@@ -266,6 +267,7 @@ export function registerDirectoryCli(program: Command) {
.option("--limit <n>", "Limit results")
.action(async (opts) => {
try {
const limit = parseLimit(opts.limit);
const { cfg, channelId, accountId, plugin } = await resolve({
channel: opts.channel as string | undefined,
account: opts.account as string | undefined,
@@ -282,7 +284,7 @@ export function registerDirectoryCli(program: Command) {
cfg,
accountId,
groupId,
limit: parseLimit(opts.limit),
limit,
runtime: defaultRuntime,
});
if (opts.json) {