generated from bennycode/ts-node-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrompt.ts
21 lines (21 loc) · 894 Bytes
/
Prompt.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export interface Prompt<T> {
/**
* Key for the answer which will be used to store its parsed value in the 'answers' object, which will be returned at the end of the conversation.
*/
answerKey: string;
/**
* Function which validates, parses and returns the value from a user's answer to the current question. If the user's input is invalid, the
* function should throw an `Error` with a meaningful message that can be sent back to the user.
* @param answer - A user's answer to the current question.
* @param answers - All answers to previously asked questions.
*/
answerValue: (answer: string, answers: Record<string, T>) => T;
/**
* A question, which is asked to the user.
*/
question: (() => string) | string;
/**
* A reply which will be sent to the user when the question is answered with valid input.
*/
response: (() => string) | string;
}