Input
The Input prompt is a simple text input with support for
auto suggestions.
The Input prompt can be imported from prompt/mod.ts or prompt/input.ts.
import { Input } from "@cliffy/prompt/input";
const name: string = await Input.prompt("What's your github user name?");Copydeno run examples/prompt/input.tsCopyOptions
The Input prompt implements all base and
auto suggestion options and the following prompt
specific options.
Min input length
The minLength option specifies the minimum length of the input value. Default
is 0.
Max input length
The maxLength option specifies the maximum length of the input value. Default
is infinity.
List pointer
With the listPointer you specify the list pointer icon. Default is ❯.
Display usage info
The info option enables the info bar which displays some usage information.
Auto suggestions
Tab-completions can be enabled with the suggestions and/or id option. If an
id is provided, the value 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. You can read more about auto
suggestions here.
i❕ The
idoption requires deno >=1.10and the--locationflag. Since deno1.16.0the--locationflag is optional.
import { Input } from "@cliffy/prompt/input";
const color: string = await Input.prompt({
  message: "Choose a color",
  id: "<local-storage-key>",
  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_prompt.tsCopy