MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseNumericFlag

Function parseNumericFlag

packages/cli/src/cloud/parsing.ts:48–64  ·  view source on GitHub ↗
(
  raw: string | undefined,
  opts: FloatFlagOptions,
)

Source from the content-addressed store, hash-verified

46 * input. Accepts integers and decimals.
47 */
48export function parseNumericFlag(
49 raw: string | undefined,
50 opts: FloatFlagOptions,
51): number | undefined {
52 if (raw === undefined) return undefined;
53 if (!NUMERIC_RE.test(raw)) {
54 errorBox(`Invalid ${opts.flag}`, `Got "${raw}". Must be a number${rangeSuffix(opts)}.`);
55 process.exit(1);
56 }
57 const n = Number.parseFloat(raw);
58 if (!Number.isFinite(n)) {
59 errorBox(`Invalid ${opts.flag}`, `Got "${raw}". Must be a finite number.`);
60 process.exit(1);
61 }
62 enforceRange(opts.flag, raw, n, opts);
63 return n;
64}
65
66function enforceRange(
67 flag: string,

Callers 3

parsing.test.tsFile · 0.85
parsePollIntervalMsFunction · 0.85
parseMaxWaitMsFunction · 0.85

Calls 3

errorBoxFunction · 0.85
rangeSuffixFunction · 0.85
enforceRangeFunction · 0.85

Tested by

no test coverage detected