Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/deps/question/list.ts>default

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function default
import { default } from "https://deno.land/x/netzo@0.5.14/deps/question/list.ts";

Creates a list of selectable items from which one item can 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 the result.

This control supports filtering by the label set by the option. To get started with the default configuration set the filtering list 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 return undefined.
  • Ctrl+d will exit the whole script no questions asked with a Deno.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.
  • Enter will return the currently selected item.

Requires --unstable until Deno version 1.27.

Type Parameters

optional
T = string

Parameters

label: string

The label the question will have.

options: string[] | Record<string, T>

The options the user has to choose from.

optional
listOptions: ListOptions

Returns

Promise<T | undefined>

The selected option or undefined if canceled or empty.