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

Function parseEnumFlag

packages/cli/src/cloud/parsing.ts:83–92  ·  view source on GitHub ↗
(
  raw: string | undefined,
  allowed: readonly T[],
  opts: { flag: string },
)

Source from the content-addressed store, hash-verified

81
82/** Parse an enum-typed flag against a closed set of allowed values. */
83export function parseEnumFlag<T extends string>(
84 raw: string | undefined,
85 allowed: readonly T[],
86 opts: { flag: string },
87): T | undefined {
88 if (raw === undefined) return undefined;
89 if ((allowed as readonly string[]).includes(raw)) return raw as T;
90 errorBox(`Invalid ${opts.flag}`, `Got "${raw}". Must be one of: ${allowed.join(", ")}.`);
91 process.exit(1);
92}
93
94function rangeSuffix(opts: { min?: number; max?: number }): string {
95 if (opts.min !== undefined && opts.max !== undefined) return ` (${opts.min}-${opts.max})`;

Callers 2

parsing.test.tsFile · 0.85
runFunction · 0.85

Calls 1

errorBoxFunction · 0.85

Tested by

no test coverage detected