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.comCopyOptions
Suggestions
The suggestions options specifies a list of default suggestions.
import { Input } from "@cliffy/prompt/input";
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 });Copydeno run examples/prompt/suggestions.tsCopyLocal 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
idoption requires deno >=1.10and the--locationflag. Since deno1.16.0the--locationflag is optional.
Path completions
To enable path completions for relative and absolute files, set the files
option to true. Path completions is only available for Input and List
prompts.
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 "@cliffy/prompt/input";
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 });Copydeno run examples/prompt/suggestions_list.tsCopyMax suggestions
With the maxRows option you specify the number of suggestions displayed per
page. Defaults to 10.