(raw: string | undefined, opts: IntFlagOptions)
| 25 | * supply their own defaults. |
| 26 | */ |
| 27 | export function parseIntFlag(raw: string | undefined, opts: IntFlagOptions): number | undefined { |
| 28 | if (raw === undefined) return undefined; |
| 29 | if (!INTEGER_RE.test(raw)) { |
| 30 | errorBox(`Invalid ${opts.flag}`, `Got "${raw}". Must be an integer${rangeSuffix(opts)}.`); |
| 31 | process.exit(1); |
| 32 | } |
| 33 | const n = Number.parseInt(raw, 10); |
| 34 | enforceRange(opts.flag, raw, n, opts); |
| 35 | return n; |
| 36 | } |
| 37 | |
| 38 | export interface FloatFlagOptions { |
| 39 | flag: string; |
no test coverage detected