(raw: string | undefined, flagName: string)
| 467 | } |
| 468 | |
| 469 | function parseFlag(raw: string | undefined, flagName: string): number | undefined { |
| 470 | if (raw === undefined) return undefined; |
| 471 | const n = Number(raw); |
| 472 | if (!Number.isFinite(n)) { |
| 473 | throw ApiError.fromEnvelope({ |
| 474 | error: { |
| 475 | code: 'VALIDATION_ERROR', |
| 476 | message: 'Invalid request.', |
| 477 | nextAction: `Flag \`--${flagName}\` is invalid: must be an integer.`, |
| 478 | requestId: 'local', |
| 479 | details: { field: flagName, reason: 'must be an integer' }, |
| 480 | }, |
| 481 | }); |
| 482 | } |
| 483 | return n; |
| 484 | } |
| 485 | |
| 486 | function resolveCommonOptions(command: Command): CommonOptions { |
| 487 | const globals = command.optsWithGlobals() as Partial<CommonOptions> & { |
no test coverage detected