❓ CLI interactive prompts. Currently just wrapping the question
method of
Node's readline
module. This obviously makes this package "Node only", even if
it uses ESM.
First:
# If you use npm
npm install @vangware/prompts
# If you use pnpm
pnpm add @vangware/prompts
# If you use yarn
yarn add @vangware/prompts
And then:
import { question } from "@vangware/prompts";
import { createInterface } from "node:readline/promises";
const readlineInterface = createInterface({
input: process.stdin,
output: process.stdout,
});
question({
format: value => parseInt(value, 18),
query: "How old are you?",
readlineInterface,
validate: value => (value < 18 ? "You must be at least 18 years old." : ""),
})
.then(console.log)
.catch(console.error)
.finally(() => readlineInterface.close());
Documentation is available HERE. It is auto-generated with typedoc based on the JSDocs and the types in the source. It shouldn't be necessary to read this. Code editors like VS Code integrate the documentation in the UI.
Changelog can be found HERE.
Test coverage can be found HERE.