Function: Choices()
ts
function Choices<T>(...values): FlagTypeFunction<T>;Defined in: packages/parser/src/flag-types.ts:17
Creates a Choices type function that validates the input against allowed values. The display name will be formatted as "value1 | value2 | ..." for help output.
Type Parameters
| Type Parameter |
|---|
T extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
...values | T[] | Array of allowed string values |
Returns
A FlagTypeFunction that validates and returns the input value
Throws
If the value is not in the allowed values list
Example
typescript
const format = Choices(["json", "yaml", "xml"]);
// Help output will show: json | yaml | xml
