2023-11-28 00:14:54 +01:00

1.7 KiB

Title: Text prompt Order: 0 RedirectFrom: prompt Description: "Spectre.Console has multiple input functions for helping receive strongly typed input from a user." Highlights: - Confirmation. - Strongly typed input. - Input restricted to specific items. - Secrets such as passwords or keys.

Sometimes you want to get some input from the user, and for this you can use the Prompt<TResult>.

The use of prompts insides status or progress displays is not supported.

Confirmation

Run prompt example? [y/n] (y): _

Simple

What's your name? Patrik
What's your age? 37

Choices

What's your favorite fruit? [Apple/Banana/Orange] (Orange): _

Validation

What's the secret number? 32
Too low
What's the secret number? 102
Too high
What's the secret number? _

Secrets

Enter password: ************_

Masks

Enter password: ------------_

You can utilize a null character to completely hide input.

Enter password: _

Optional

[Optional] Favorite color? _