Skip to content

[feature]: Implement valueToEndPrompt #7

@azmizar

Description

@azmizar

Is your feature request related to a problem? Please describe.
valueToEndPrompt is to allow prompt to gracefully stop. It is useful for consumer to know if the user explicitly wants to stop from entering input (and usually intended to stop the process). In multi-prompts session, prompt will stop requesting input from user even if it has not completed all of the prompts yet.

Describe the solution you'd like
During gathering session, consumer may want to allow user to end the session gracefully. Prompt should check the entered value and if it matches valueToEndPrompt, it should stop the session:

  • Stops executing the rest of the prompts in multi-prompts session
  • Sets userEndedSession flag to true of PromptResult for the prompt when the client entered the value

Consumer will receive an array of PromptResult from beginning up to when the user entered the value. For example, if there are 10 prompts, and user entered the value on the 5th prompt, consumer will only get prompt results from [0-4].

Describe alternatives you've considered
The current endIfEmpty throws an Error('User did not enter value') (as .catch()) and consumer will have to check the error returned in order to know that the user ended the session. This flag is more to implicit stop instead of explicit stop (i.e.: user may accidentally hit enter and this flag will stops the prompt from moving forward).

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions