Cliffy

Auto suggestions

You can provide suggestions to the input, number and list prompt to enable tab-completions with the suggestions and/or id option. If an id is provided, the values will be saved to the local storage using the id as local storage key. With suggestions you can provide some default suggestions. Both options can be defined at the same time.

deno install you/cli.ts --location https://example.com
# or
deno run you/cli.ts --location https://example.comCopy

Options

Suggestions

The suggestions options specifies a list of default suggestions.

import { Input } from "https://deno.land/x/cliffy@v0.24.2/prompt/input.ts";

const color: string = await Input.prompt({
  message: "Choose a color",
  suggestions: [
    "Abbey",
    "Absolute Zero",
    "Acadia",
    "Acapulco",
    "Acid Green",
    "Aero",
    "Aero Blue",
    "Affair",
    "African Violet",
    "Air Force Blue",
  ],
});

console.log({ color });Copy
$ deno run --unstable https://deno.land/x/cliffy@v0.24.2/examples/prompt/suggestions.tsCopy

Local storage id

If the id option is provided, values are stored in the local storage using the id as local storage key. The stored values are used as suggestions at the next time the prompt is used.

i

❕ The id option requires deno >= 1.10 and the --location flag. Since deno 1.16.0 the --location flag is optional.

Suggestions list

With the list option you can display a list of suggestions. Matched suggestions will be highlighted in the list and can be completed with the tab key.

You can also display the info bar with the info option to show the number of available suggestions and usage information.

import { Input } from "https://deno.land/x/cliffy@v0.24.2/prompt/input.ts";

const color: string = await Input.prompt({
  message: "Choose a color",
  list: true,
  info: true,
  suggestions: [
    "Abbey",
    "Absolute Zero",
    "Acadia",
    "Acapulco",
    "Acid Green",
    "Aero",
    "Aero Blue",
    "Affair",
    "African Violet",
    "Air Force Blue",
  ],
});

console.log({ color });Copy
$ deno run --unstable https://deno.land/x/cliffy@v0.24.2/examples/prompt/suggestions_list.tsCopy

Max suggestions

With the maxRows option you specify the number of suggestions displayed per page. Defaults to 10.