import { Select } from "https://deno.land/x/wmill@v1.364.1/deps.ts";
Select prompt representation.
Simple prompt:
import { Select } from "./mod.ts";
const color: string = await Select.prompt({
message: "Pick a color",
options: ["red", "green", "blue"],
});
Mixed option types:
import { Select } from "./mod.ts";
const value: string | number = await Select.prompt<string | number>({
message: "Pick a color",
options: [1, 2, "3", "4"],
});
None primitive option types:
import { Select } from "./mod.ts";
const date: Date = await Select.prompt({
message: "Pick a date",
options: [
{
name: "Date 1",
value: new Date(100000),
},
{
name: "Date 2",
value: new Date(200000),
},
{
name: "Date 3",
value: new Date(300000),
},
],
});
Grouped options:
import { Select } from "./mod.ts";
const value = await Select.prompt({
message: "Select a value",
options: [{
name: "Group 1",
options: ["foo", "bar", "baz"],
}, {
name: "Group 2",
options: ["beep", "boop"],
}],
});
Constructors
new
Select(options: SelectOptions<TValue>)Methods
protected
input(): stringprotected
mapOptions(promptOptions: SelectOptions<TValue>, options: Array<>): Array<SelectOptionSettings<TValue> | SelectOptionGroupSettings<TValue>>Map string option values to options and set option defaults.
protected
submit(): Promise<void>getDefaultSettings(options: SelectOptions<TValue>): SelectSettings<TValue>
Static Methods
inject(value: string): void
Inject prompt value. If called, the prompt doesn't prompt for an input and returns immediately the injected value. Can be used for unit tests or pre selections.