Interactive command-line prompts for Deno.
ask
is a slick Deno module that allows you to create interactive command-line
applications, similar to what you'd achieve with
inquirer in Node.js.
input
(plain text)number
(integer or float)password
(hidden/masked input)confirm
(yes/no)editor
(open an editor to write longer text)select
(pick one item from a list)checkbox
(pick multiple items from a list)First, install the package from JSR:
deno add jsr:@sallai/ask
Then just create an Ask
instance and use the prompt()
method to enumerate
your questions.
import { Ask } from "@sallai/ask"; const ask = new Ask(); // global options are also supported! const answers = await ask.prompt([ { name: "name", type: "input", message: "Name:", }, { name: "age", type: "number", message: "Age:", }, ] as const); console.log(answers); // { name: "Joe", age: 19 }
You can also just ask a single question:
const { name } = await ask.input({ name: "name", message: "Name:", } as const); console.log(name); // Joe
Note: The
as const
assertion is necessary to ensure that thename
property is not widened tostring
. This is necessary for the type-checking to work properly.
Please visit the JSR documentation page for more information on how to use the library.
MIT.
Add Package
deno add jsr:@sallai/ask
Import symbol
import * as ask from "@sallai/ask";
---- OR ----
Import directly with a jsr specifier
import * as ask from "jsr:@sallai/ask";