(value: string | undefined)
| 328 | } |
| 329 | |
| 330 | function parseContextFields(value: string | undefined): ContextField[] { |
| 331 | if (value === undefined) return DEFAULT_CONTEXT_FIELDS; |
| 332 | if (!value.trim()) throw new Error("--context-fields cannot be empty"); |
| 333 | const allowed = new Set<ContextField>(DEFAULT_CONTEXT_FIELDS); |
| 334 | const fields = value |
| 335 | .split(",") |
| 336 | .map((field) => field.trim()) |
| 337 | .filter(Boolean); |
| 338 | const invalid = fields.filter((field) => !allowed.has(field as ContextField)); |
| 339 | if (invalid.length > 0) { |
| 340 | throw new Error( |
| 341 | `Unknown context field${invalid.length === 1 ? "" : "s"}: ${invalid.join(", ")}`, |
| 342 | ); |
| 343 | } |
| 344 | return [...new Set(fields)] as ContextField[]; |
| 345 | } |
| 346 | |
| 347 | function contextIncludes(fields: ContextField[], field: ContextField): boolean { |
| 348 | return fields.includes(field); |
no outgoing calls
no test coverage detected