Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/question/confirm.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.107/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 return undefined.
  • Ctrl+d will exit the whole script no questions asked with a Deno.exit().
  • Up arrow or Home key will move the cursor to the start of the prompt text.
  • Down arrow or End 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

label: string

The label the question will have.

optional
defaultValue: boolean | ConfirmOptions | undefined

The value that will determine the resulting value if none was provided.

Returns

Promise<boolean | undefined>

The boolean value from the answer or undefined if canceled.