import { default } from "https://deno.land/x/netzo@0.5.65/deps/question/confirm.ts";
Create a confirmation question that resolves to a true or false based on user input. It
takes an undefined
, true
, or false
value as the default value. Each of the default
value types has an effect on how the prompt looks like.
undefined
will suffix the prompt with[y/n]
true
will suffix the prompt with[Y/n]
false
will suffix the prompt with[y/N]
The only valid values are anything starting with y or n uppercase or lowercase. The y and
n is derived from the positive and negative labels. You can customize the labels in the
options object The prompt can be canceled and will then return undefined
.
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 orHome
key will move the cursor to the start of the prompt text.Down
arrow orEnd
key will move the cursor to the end of the prompt text.Left
arrow will move the cursor one step to the left once if able.Right
arrow will move the cursor one step to the right once if able.Enter
will return the parsed result of the text.
Requires --unstable
until Deno version 1.27.
Parameters
optional
defaultValue: boolean | ConfirmOptions | undefinedThe value that will determine the resulting value if none was provided.