Skip to content

Allow user to cancel input during Prompt() #1392

@kentico-ericd

Description

@kentico-ericd

Is your feature request related to a problem? Please describe.
When requesting user input multiple times, it would be nice to provide a way for the user to return to previous steps in case they've entered some wrong information.

Describe the solution you'd like
We could capture the ESC keypress during AnsiConsole.Prompt and set a variable, e.g. AnsiConsole.Prompt(prompt, out var cancelled) to indicate the user pressed escape. Or, the return value of AnsiConsole.Prompt could be null if the input was cancelled.

Describe alternatives you've considered
There are some incomplete code samples here that I've tried, but there are multiple issues with the code such as exceptions and formatting problems. It would be great if this was a native solution in Spectre.Console.


Please upvote 👍 this issue if you are interested in it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo 🕑

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions