MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / parseEnumFlag

Function parseEnumFlag

src/commands/test.ts:7645–7655  ·  view source on GitHub ↗
(
  raw: string | undefined,
  flagName: string,
  accepted: ReadonlyArray<T>,
)

Source from the content-addressed store, hash-verified

7643}
7644
7645function parseEnumFlag<T extends string>(
7646 raw: string | undefined,
7647 flagName: string,
7648 accepted: ReadonlyArray<T>,
7649): T | undefined {
7650 if (raw === undefined) return undefined;
7651 if (!accepted.includes(raw as T)) {
7652 throw localValidationError(flagName, `must be one of: ${accepted.join(', ')}`, [...accepted]);
7653 }
7654 return raw as T;
7655}
7656
7657function parseNumericFlag(raw: string | undefined, flagName: string): number | undefined {
7658 if (raw === undefined) return undefined;

Callers 2

createTestCommandFunction · 0.85
createTestCodeCommandFunction · 0.85

Calls 1

localValidationErrorFunction · 0.70

Tested by

no test coverage detected