Skip to content

Commit

Permalink
Chore(@inquirer/rawlist) Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jul 28, 2024
1 parent f881e68 commit 083e122
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions packages/rawlist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,33 @@ const answer = await rawlist({

## Options

| Property | Type | Required | Description |
| -------- | ------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| message | `string` | yes | The question to ask |
| choices | `Array<{ value: string, name?: string, key?: string }>` | yes | List of the available choices. The `value` will be returned as the answer, and used as display if no `name` is defined. By default, choices will be selected by index. This can be customized by using the `key` option. |
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
| Property | Type | Required | Description |
| -------- | ----------------------- | -------- | ------------------------------ |
| message | `string` | yes | The question to ask |
| choices | `Choice[]` | yes | List of the available choices. |
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |

`Separator` objects can be used in the `choices` array to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (`new Separator('-- Dependencies --')`). This option is often used to add labels to groups within long list of options.

### `Choice` object

The `Choice` object is typed as

```ts
type Choice<Value> = {
value: Value;
name?: string;
short?: string;
key?: string;
};
```

Here's each property:

- `value`: The value is what will be returned by `await select()`.
- `name`: This is the string displayed in the choice list.
- `short`: Once the prompt is done (press enter), we'll use `short` if defined to render next to the question. By default we'll use `name`.
- `key`: The key of the choice. Displayed as `key) name`.

## Theming

Expand Down

0 comments on commit 083e122

Please sign in to comment.