|
1 | 1 | import type { Command } from "commander"; |
2 | | -import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse } from "../../helpers.js"; |
| 2 | +import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse, parseNonNegativeInt, buildPaginationParams } from "../../helpers.js"; |
3 | 3 | import { loadConfig, saveConfig } from "../../config.js"; |
4 | 4 | import { parseJsonInput } from "../../input.js"; |
5 | 5 | import { printApiKeyBox, printError } from "../../output.js"; |
@@ -109,17 +109,15 @@ export function registerApiKeysCommand(parent: Command): void { |
109 | 109 | .command("list") |
110 | 110 | .description("List all API keys, showing name, tenant, policy, and status (key values are masked)") |
111 | 111 | .option("--tenant-id <id>", "Filter by tenant ID") |
112 | | - .option("--limit <n>", "Maximum number of results", parseInt) |
113 | | - .option("--offset <n>", "Skip N results", parseInt) |
| 112 | + .option("--limit <n>", "Maximum number of results", parseNonNegativeInt) |
| 113 | + .option("--offset <n>", "Skip N results", parseNonNegativeInt) |
114 | 114 | .action( |
115 | 115 | withErrorHandler(async (_opts: unknown, cmd: Command) => { |
116 | 116 | const opts = cmd.opts() as { tenantId?: string; limit?: number; offset?: number }; |
117 | 117 | const client = createClient(cmd); |
118 | 118 | const format = getFormat(cmd); |
119 | | - const params: Record<string, string> = {}; |
| 119 | + const params: Record<string, string> = buildPaginationParams(opts); |
120 | 120 | if (opts.tenantId) params.tenantId = opts.tenantId; |
121 | | - if (opts.limit !== undefined) params.limit = String(opts.limit); |
122 | | - if (opts.offset !== undefined) params.offset = String(opts.offset); |
123 | 121 | const response = await client.rawRequest("GET", "/admin/api-keys", { |
124 | 122 | params, |
125 | 123 | }); |
|
0 commit comments