Skip to content

Confirm & Number

import { confirm } from "@arshad-shah/clif/prompts";
const proceed = await confirm({
message: "Deploy to production?",
default: false,
});
if (proceed) {
// deploy
}

Displays (Y/n) or (y/N) based on the default. A single y/n keypress resolves immediately (no Enter needed); pressing Enter alone returns the default. Piped input also accepts a full y/yes line (case-insensitive).

OptionTypeDescription
messagestringPrompt message
defaultbooleanValue used when Enter is hit
import { number } from "@arshad-shah/clif/prompts";
const port = await number({
message: "Port number:",
default: 3000,
min: 1024,
max: 65535,
step: 1,
});

Validates that input is a finite number, within the optional min/max range, and (if step is set) a multiple of step anchored to min (so min: 1, step: 2 accepts 1, 3, 5, …). Invalid input re-prompts with a descriptive error.

You can type a value directly, or use the ↑ / ↓ arrow keys to step the current value by step (defaulting to 1), clamped to min/max.

OptionTypeDescription
messagestringPrompt message
defaultnumberValue used when Enter is hit
minnumberMinimum allowed value (inclusive)
maxnumberMaximum allowed value (inclusive)
stepnumberRequired step grid (e.g. 5 → accepts 0, 5, 10, …)
requiredbooleanReject empty input (otherwise empty falls back to default)