The long
question type lets you collect multiple lines of text from the user, similar to a textarea
.
Here's a quick example:
await form.long('What is your favorite poem?');
Which generates a question that looks like this:
long()
returns a string
containing the user's answer, which you can use in the rest of the script:
let poem = await form.long('What is your favorite poem?');
if (poem.toLowerCase().includes("roses are red")) {
await form.statement("You can do better, no clichés allowed!");
} else {
await form.statement("Great choice!");
}
Using the answer from one question within the text of a subsequent question is a special case that requires a tiny bit of extra care. More details on the Interpolation page.
You can pass options to long
like so:
let poem = await form.long('What is your favorite poem?', {
value: 'Quoth the Raven: "Nevermore."'
});
Here's a list of all long
-specific options:
Option | Type | |
---|---|---|
value |
string |
Prefill the answer with this value |
You can also pass global options, which are valid for all question types.