promptMultipleSelect
import { promptMultipleSelect } from "jsr:@ende/cli/unstable-prompt-multiple-select";function · experimental
function promptMultipleSelect<V = undefined>(message: string, values: PromptEntry<V>[], options: PromptMultipleSelectOptions = [UNSUPPORTED]): PromptEntry<V>[] | nullShows the given message and waits for the user's input. Returns the user's selected value as string.
Also supports filtering of the options by typing.
message: stringThe prompt message to show to the user.
values: PromptEntry<V>[]The values for the prompt.
options: PromptMultipleSelectOptions = [UNSUPPORTED]The options for the prompt.
Returns
The selected values as an array of strings or null if stdin is not a TTY.
Example: Usage
import { promptMultipleSelect } from "@ende/cli/unstable-prompt-multiple-select";
const browsers = promptMultipleSelect(
"Please select browsers:",
["safari", "chrome", "firefox"],
{ clear: true },
);
Example: With title and value
import { promptMultipleSelect } from "@ende/cli/unstable-prompt-multiple-select";
const browsers = promptMultipleSelect(
"Please select browsers:",
[{
label: "safari",
value: 1,
}, {
label: "chrome",
value: 2,
}, {
label: "firefox",
value: 3,
}],
{ clear: true },
);
Example: With multiple options
import { promptMultipleSelect } from "@ende/cli/unstable-prompt-multiple-select";
const browsers = promptMultipleSelect(
"Select your favorite numbers below 100:",
[...Array(100).keys()].map(String),
{ clear: true, visibleLines: 5, indicator: "→" },
);