import { default } from "https://deno.land/x/netzo@0.5.65/deps/question/checkbox.ts";
Creates a list of selectable items from which one item will be chosen. If no items are available
to be selected this will return undefined
without a question prompt.
The options parameter can also be a plain object where the key is the label and the value is a object definition how the option is represented in the list and with a value. The representation keys are:
dependencies
: This is a value that takes a index, label, or a list of indices and labels to express the reliance of a different option. So whenever any dependant option is select this one is too. Same for deselects.selected
: This makes the option selected by default. If the option depends on any other options They will also be selected.
const options = {
'Value 1': { value: 1 },
'Value 2': { value: 2 },
'Value 3': { value: 3 },
}
const options = {
'Value 1': { value: 1 },
'Value 2': { value: 2, dependencies: ['Value 1'] },
'Value 3': { value: 3, selected: true },
}
This control supports filtering by the label set by the option. To get started with the default
configuration set the filtering
checkbox option to true. It will try to match the characters
input with the label values.
The filtering has support to be able to search by exact label value, highlight the sections on the label that is matching the string, only sort the options by the string instead to removing the non matching options, and sort the options by specificity rank or the specified manual sorting.
Controls:
Ctrl+c
will have the question canceled and returnundefined
.Ctrl+d
will exit the whole script no questions asked with aDeno.exit()
.Up
arrow will move the selected item up once if able.Down
arrow will move the selected item down once if able.Home
will move the selected item up to the start if able.End
will move the selected item down to the end if able.PageUp
will move the selected item up by the actual list window size if able.PageDown
will move the selected item down by the actual list window size if able.Space
will mark/unmark the selected item.Enter
will return all marked items in a list.
Requires --unstable
until Deno version 1.27.
Parameters
The options the user has to choose from.