Only a person at a terminal is asked. An agent, CI or a pipe never waits on stdin: the answer comes from a flag, --input or a variable, or the command uses the default and says how to change it.
confirm
Section titled "confirm"const fix = await out.confirm({
name: "fix",
flag: "--fix",
default: false,
message: "Apply 2 safe fixes?",
reason: "applies 2 safe fixes",
});At a terminal it asks ? Apply 2 safe fixes? (y/N). Every other reader gets the default, and a default of no adds the next line acme check --fix with its reason. Pass the flag's value as value once the command has parsed it.
const account = await out.ask({
name: "account",
flag: "--account",
env: "ACME_ACCOUNT",
choices: ["personal", "team"],
message: "Account",
});ask takes a string, from choices when they are given. With no answer and no default, the command fails with exit 2, naming the flag, the variable and --input as ways to pass it, and acme deploy --account <account> as the command to run instead.
Where an answer comes from
Section titled "Where an answer comes from"The flag
Section titled "The flag"Such as
--account team, asvalue.
Section titled "--input"--input--input '{"account": "team"}', by name, from inline JSON,@fileor@-for stdin.The variable
Section titled "The variable"Such as
ACME_ACCOUNT=team.For a confirm only.
A prompt
Section titled "A prompt"Only for a person at a terminal, on the
textformat, with stdin and stderr on a TTY and no--no-input.The default
Section titled "The default"With a next line that names the flag.
A failure
Section titled "A failure"action_required, exit 2, with what is missing and the command to run instead.
A confirm that needs the name
Section titled "A confirm that needs the name"await out.confirm({
name: "project",
flag: "--delete",
message: "Delete acme-web?",
requireExact: "acme-web",
});Only the typed name confirms it, at the prompt or as the flag's value. --yes and a default of true don't.