mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 18:40:50 +08:00 
			
		
		
		
	Docs redesign (#728)
* Adding a dark mode * Adding reference for types to summary pages * Adding API Reference * Adding modifiers to methods/fields/etc * Minimizing files input * Caching a lot of the output pages * Cache only for each execution * Adding API references to existing docs
This commit is contained in:
		@@ -21,26 +21,15 @@ you can use the `Prompt<TResult>`.
 | 
			
		||||
 | 
			
		||||
## Confirmation
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
if (!AnsiConsole.Confirm("Run example?"))
 | 
			
		||||
{
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskConfirmation" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
Run example? [y/n] (y): _
 | 
			
		||||
Run prompt example? [y/n] (y): _
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Simple
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
// Ask for the user's name
 | 
			
		||||
string name = AnsiConsole.Ask<string>("What's your [green]name[/]?");
 | 
			
		||||
 | 
			
		||||
// Ask for the user's age
 | 
			
		||||
int age = AnsiConsole.Ask<int>("What's your [green]age[/]?");
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskName" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
What's your name? Patrik
 | 
			
		||||
@@ -49,15 +38,7 @@ What's your age? 37
 | 
			
		||||
 | 
			
		||||
## Choices
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var fruit = AnsiConsole.Prompt(
 | 
			
		||||
    new TextPrompt<string>("What's your [green]favorite fruit[/]?")
 | 
			
		||||
        .InvalidChoiceMessage("[red]That's not a valid fruit[/]")
 | 
			
		||||
        .DefaultValue("Orange")
 | 
			
		||||
        .AddChoice("Apple")
 | 
			
		||||
        .AddChoice("Banana")
 | 
			
		||||
        .AddChoice("Orange"));
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskFruit" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
What's your favorite fruit? [Apple/Banana/Orange] (Orange): _
 | 
			
		||||
@@ -65,19 +46,7 @@ What's your favorite fruit? [Apple/Banana/Orange] (Orange): _
 | 
			
		||||
 | 
			
		||||
## Validation
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var age = AnsiConsole.Prompt(
 | 
			
		||||
    new TextPrompt<int>("What's the secret number?")
 | 
			
		||||
        .Validate(age =>
 | 
			
		||||
        {
 | 
			
		||||
            return age switch
 | 
			
		||||
            {
 | 
			
		||||
                < 99 => ValidationResult.Error("[red]Too low[/]"),
 | 
			
		||||
                > 99 => ValidationResult.Error("[red]Too high[/]"),
 | 
			
		||||
                _ => ValidationResult.Success(),
 | 
			
		||||
            };
 | 
			
		||||
        }));
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskAge" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
What's the secret number? 32
 | 
			
		||||
@@ -89,12 +58,8 @@ What's the secret number? _
 | 
			
		||||
 | 
			
		||||
## Secrets
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var password = AnsiConsole.Prompt(
 | 
			
		||||
    new TextPrompt<string>("Enter [green]password[/]")
 | 
			
		||||
        .PromptStyle("red")
 | 
			
		||||
        .Secret());
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskPassword" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
Enter password: ************_
 | 
			
		||||
@@ -102,11 +67,7 @@ Enter password: ************_
 | 
			
		||||
 | 
			
		||||
## Optional
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var color = AnsiConsole.Prompt(
 | 
			
		||||
    new TextPrompt<string>("[grey][[Optional]][/] [green]Favorite color[/]?")
 | 
			
		||||
        .AllowEmpty());
 | 
			
		||||
```
 | 
			
		||||
<?# Example symbol="M:Prompt.Program.AskColor" project="Prompt" /?>
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
[Optional] Favorite color? _
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user