mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00

* Masking Character added, not yet used. * Setting the masking character can be chained with other extensions. * Added string extension for masking, and replaced hardcoded asterisks. * Check if mask is null first. * Fixed Typo in previous test and added new test for custom masks. * Added tests for masking with null character * Added docs and example. * Adjusted extensions so that Mask is integrated into Secret extension. Updated Exampls and Tests accordingly
1.7 KiB
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? _