mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
fixed line-endings
This commit is contained in:

committed by
Patrik Svensson

parent
989c0b9904
commit
44300c871f
@ -4,7 +4,7 @@ Description: "*Spectre.Console* makes it easy to write text with different style
|
||||
Highlights:
|
||||
- Bold, Italic, Underline, strikethrough
|
||||
- Dim, Invert
|
||||
- Conceal, slowblink, rapidblink
|
||||
- Conceal, slowblink, rapidblink
|
||||
- Links
|
||||
---
|
||||
|
||||
@ -46,9 +46,9 @@ Note that what styles that can be used is defined by the system or your terminal
|
||||
<tr>
|
||||
<td><code>strikethrough</code></td>
|
||||
<td>Shows text with a horizontal line through the center</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>link</link></td>
|
||||
<td>Creates a clickable link within text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>link</link></td>
|
||||
<td>Creates a clickable link within text</td>
|
||||
</tr>
|
||||
</table>
|
@ -1,47 +1,47 @@
|
||||
Title: Command Help
|
||||
Order: 13
|
||||
Description: "Console applications built with *Spectre.Console.Cli* include automatically generated help command line help."
|
||||
---
|
||||
|
||||
Console applications built with `Spectre.Console.Cli` include automatically generated help which is displayed when `-h` or `--help` has been specified on the command line.
|
||||
|
||||
The automatically generated help is derived from the configured commands and their command settings.
|
||||
|
||||
The help is also context aware and tailored depending on what has been specified on the command line before it. For example,
|
||||
|
||||
1. When `-h` or `--help` appears immediately after the application name (eg. `application.exe --help`), then the help displayed is a high-level summary of the application, including any command line examples and a listing of all possible commands the user can execute.
|
||||
|
||||
2. When `-h` or `--help` appears immediately after a command has been specified (eg. `application.exe command --help`), then the help displayed is specific to the command and includes information about command specific switches and any default values.
|
||||
|
||||
`HelpProvider` is the `Spectre.Console` class responsible for determining context and preparing the help text to write to the console. It is an implementation of the public interface `IHelpProvider`.
|
||||
|
||||
## Custom help providers
|
||||
|
||||
Whilst it shouldn't be common place to implement your own help provider, it is however possible.
|
||||
|
||||
You are able to implement your own `IHelpProvider` and configure a `CommandApp` to use that instead of the Spectre.Console help provider.
|
||||
|
||||
```csharp
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace Help;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
var app = new CommandApp<DefaultCommand>();
|
||||
|
||||
app.Configure(config =>
|
||||
{
|
||||
// Register the custom help provider
|
||||
config.SetHelpProvider(new CustomHelpProvider(config.Settings));
|
||||
});
|
||||
|
||||
return app.Run(args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
There is a working [example of a custom help provider](https://github.com/spectreconsole/spectre.console/tree/main/examples/Cli/Help) demonstrating this.
|
||||
|
||||
Title: Command Help
|
||||
Order: 13
|
||||
Description: "Console applications built with *Spectre.Console.Cli* include automatically generated help command line help."
|
||||
---
|
||||
|
||||
Console applications built with `Spectre.Console.Cli` include automatically generated help which is displayed when `-h` or `--help` has been specified on the command line.
|
||||
|
||||
The automatically generated help is derived from the configured commands and their command settings.
|
||||
|
||||
The help is also context aware and tailored depending on what has been specified on the command line before it. For example,
|
||||
|
||||
1. When `-h` or `--help` appears immediately after the application name (eg. `application.exe --help`), then the help displayed is a high-level summary of the application, including any command line examples and a listing of all possible commands the user can execute.
|
||||
|
||||
2. When `-h` or `--help` appears immediately after a command has been specified (eg. `application.exe command --help`), then the help displayed is specific to the command and includes information about command specific switches and any default values.
|
||||
|
||||
`HelpProvider` is the `Spectre.Console` class responsible for determining context and preparing the help text to write to the console. It is an implementation of the public interface `IHelpProvider`.
|
||||
|
||||
## Custom help providers
|
||||
|
||||
Whilst it shouldn't be common place to implement your own help provider, it is however possible.
|
||||
|
||||
You are able to implement your own `IHelpProvider` and configure a `CommandApp` to use that instead of the Spectre.Console help provider.
|
||||
|
||||
```csharp
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace Help;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
var app = new CommandApp<DefaultCommand>();
|
||||
|
||||
app.Configure(config =>
|
||||
{
|
||||
// Register the custom help provider
|
||||
config.SetHelpProvider(new CustomHelpProvider(config.Settings));
|
||||
});
|
||||
|
||||
return app.Run(args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
There is a working [example of a custom help provider](https://github.com/spectreconsole/spectre.console/tree/main/examples/Cli/Help) demonstrating this.
|
||||
|
||||
|
@ -1,119 +1,119 @@
|
||||
Title: Markup
|
||||
Order: 30
|
||||
Description: The Markup class allows you to output rich text to the console.
|
||||
Highlights:
|
||||
- Easily add *color*.
|
||||
- Add hyperlinks to for supported terminals.
|
||||
- Emoji 🚀 parsing.
|
||||
Reference:
|
||||
- M:Spectre.Console.AnsiConsole.Markup(System.String)
|
||||
- M:Spectre.Console.AnsiConsole.MarkupLine(System.String)
|
||||
- T:Spectre.Console.Markup
|
||||
---
|
||||
|
||||
The `Markup` class allows you to output rich text to the console.
|
||||
|
||||
## Syntax
|
||||
|
||||
Console markup uses a syntax inspired by bbcode. If you write the style (see [Styles](xref:styles))
|
||||
in square brackets, e.g. `[bold red]`, that style will apply until it is closed with a `[/]`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Write(new Markup("[bold yellow]Hello[/] [red]World![/]"));
|
||||
```
|
||||
|
||||
The `Markup` class implements `IRenderable` which means that you
|
||||
can use this in tables, grids, and panels. Most classes that support
|
||||
rendering of `IRenderable` also have overloads for rendering rich text.
|
||||
|
||||
```csharp
|
||||
var table = new Table();
|
||||
table.AddColumn(new TableColumn(new Markup("[yellow]Foo[/]")));
|
||||
table.AddColumn(new TableColumn("[blue]Bar[/]"));
|
||||
AnsiConsole.Write(table);
|
||||
```
|
||||
|
||||
## Convenience methods
|
||||
|
||||
There are also convenience methods on `AnsiConsole` that can be used
|
||||
to write markup text to the console without instantiating a new `Markup`
|
||||
instance.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[underline green]Hello[/] ");
|
||||
AnsiConsole.MarkupLine("[bold]World[/]");
|
||||
```
|
||||
|
||||
## Escaping format characters
|
||||
|
||||
To output a `[` you use `[[`, and to output a `]` you use `]]`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[[Hello]] "); // [Hello]
|
||||
AnsiConsole.Markup("[red][[World]][/]"); // [World]
|
||||
```
|
||||
|
||||
You can also use the `EscapeMarkup` extension method.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]{0}[/]", "Hello [World]".EscapeMarkup());
|
||||
```
|
||||
You can also use the `Markup.Escape` method.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]{0}[/]", Markup.Escape("Hello [World]"));
|
||||
```
|
||||
|
||||
## Escaping Interpolated Strings
|
||||
|
||||
When working with interpolated strings, you can use the `MarkupInterpolated` and `MarkupLineInterpolated` methods to automatically escape the values in the interpolated string "holes".
|
||||
|
||||
```csharp
|
||||
string hello = "Hello [World]";
|
||||
AnsiConsole.MarkupInterpolated($"[red]{hello}[/]");
|
||||
```
|
||||
|
||||
## Setting background color
|
||||
|
||||
You can set the background color in markup by prefixing the color with `on`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[bold yellow on blue]Hello[/]");
|
||||
AnsiConsole.Markup("[default on blue]World[/]");
|
||||
```
|
||||
|
||||
## Rendering emojis
|
||||
|
||||
To output an emoji as part of markup, you can use emoji shortcodes.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("Hello :globe_showing_europe_africa:!");
|
||||
```
|
||||
|
||||
For a list of emoji, see the [Emojis](xref:emojis) appendix section.
|
||||
|
||||
## Colors
|
||||
|
||||
In the examples above, all colors were referenced by their name,
|
||||
but you can also use the hex or rgb representation for colors in markdown.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]Foo[/] ");
|
||||
AnsiConsole.Markup("[#ff0000]Bar[/] ");
|
||||
AnsiConsole.Markup("[rgb(255,0,0)]Baz[/] ");
|
||||
```
|
||||
|
||||
For a list of colors, see the [Colors](xref:colors) appendix section.
|
||||
|
||||
## Links
|
||||
|
||||
To output a clickable link, you can use the `[link]` style.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[link]https://spectreconsole.net[/]");
|
||||
AnsiConsole.Markup("[link=https://spectreconsole.net]Spectre Console Documentation[/]");
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
For a list of styles, see the [Styles](xref:styles) appendix section.
|
||||
Title: Markup
|
||||
Order: 30
|
||||
Description: The Markup class allows you to output rich text to the console.
|
||||
Highlights:
|
||||
- Easily add *color*.
|
||||
- Add hyperlinks to for supported terminals.
|
||||
- Emoji 🚀 parsing.
|
||||
Reference:
|
||||
- M:Spectre.Console.AnsiConsole.Markup(System.String)
|
||||
- M:Spectre.Console.AnsiConsole.MarkupLine(System.String)
|
||||
- T:Spectre.Console.Markup
|
||||
---
|
||||
|
||||
The `Markup` class allows you to output rich text to the console.
|
||||
|
||||
## Syntax
|
||||
|
||||
Console markup uses a syntax inspired by bbcode. If you write the style (see [Styles](xref:styles))
|
||||
in square brackets, e.g. `[bold red]`, that style will apply until it is closed with a `[/]`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Write(new Markup("[bold yellow]Hello[/] [red]World![/]"));
|
||||
```
|
||||
|
||||
The `Markup` class implements `IRenderable` which means that you
|
||||
can use this in tables, grids, and panels. Most classes that support
|
||||
rendering of `IRenderable` also have overloads for rendering rich text.
|
||||
|
||||
```csharp
|
||||
var table = new Table();
|
||||
table.AddColumn(new TableColumn(new Markup("[yellow]Foo[/]")));
|
||||
table.AddColumn(new TableColumn("[blue]Bar[/]"));
|
||||
AnsiConsole.Write(table);
|
||||
```
|
||||
|
||||
## Convenience methods
|
||||
|
||||
There are also convenience methods on `AnsiConsole` that can be used
|
||||
to write markup text to the console without instantiating a new `Markup`
|
||||
instance.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[underline green]Hello[/] ");
|
||||
AnsiConsole.MarkupLine("[bold]World[/]");
|
||||
```
|
||||
|
||||
## Escaping format characters
|
||||
|
||||
To output a `[` you use `[[`, and to output a `]` you use `]]`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[[Hello]] "); // [Hello]
|
||||
AnsiConsole.Markup("[red][[World]][/]"); // [World]
|
||||
```
|
||||
|
||||
You can also use the `EscapeMarkup` extension method.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]{0}[/]", "Hello [World]".EscapeMarkup());
|
||||
```
|
||||
You can also use the `Markup.Escape` method.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]{0}[/]", Markup.Escape("Hello [World]"));
|
||||
```
|
||||
|
||||
## Escaping Interpolated Strings
|
||||
|
||||
When working with interpolated strings, you can use the `MarkupInterpolated` and `MarkupLineInterpolated` methods to automatically escape the values in the interpolated string "holes".
|
||||
|
||||
```csharp
|
||||
string hello = "Hello [World]";
|
||||
AnsiConsole.MarkupInterpolated($"[red]{hello}[/]");
|
||||
```
|
||||
|
||||
## Setting background color
|
||||
|
||||
You can set the background color in markup by prefixing the color with `on`.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[bold yellow on blue]Hello[/]");
|
||||
AnsiConsole.Markup("[default on blue]World[/]");
|
||||
```
|
||||
|
||||
## Rendering emojis
|
||||
|
||||
To output an emoji as part of markup, you can use emoji shortcodes.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("Hello :globe_showing_europe_africa:!");
|
||||
```
|
||||
|
||||
For a list of emoji, see the [Emojis](xref:emojis) appendix section.
|
||||
|
||||
## Colors
|
||||
|
||||
In the examples above, all colors were referenced by their name,
|
||||
but you can also use the hex or rgb representation for colors in markdown.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[red]Foo[/] ");
|
||||
AnsiConsole.Markup("[#ff0000]Bar[/] ");
|
||||
AnsiConsole.Markup("[rgb(255,0,0)]Baz[/] ");
|
||||
```
|
||||
|
||||
For a list of colors, see the [Colors](xref:colors) appendix section.
|
||||
|
||||
## Links
|
||||
|
||||
To output a clickable link, you can use the `[link]` style.
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Markup("[link]https://spectreconsole.net[/]");
|
||||
AnsiConsole.Markup("[link=https://spectreconsole.net]Spectre Console Documentation[/]");
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
For a list of styles, see the [Styles](xref:styles) appendix section.
|
||||
|
@ -63,22 +63,22 @@ What's the secret number? _
|
||||
|
||||
```text
|
||||
Enter password: ************_
|
||||
```
|
||||
|
||||
## Masks
|
||||
|
||||
```
|
||||
|
||||
## Masks
|
||||
|
||||
<?# Example symbol="M:Prompt.Program.AskPasswordWithCustomMask" project="Prompt" /?>
|
||||
|
||||
|
||||
```text
|
||||
```text
|
||||
Enter password: ------------_
|
||||
```
|
||||
|
||||
You can utilize a null character to completely hide input.
|
||||
|
||||
```
|
||||
|
||||
You can utilize a null character to completely hide input.
|
||||
|
||||
<?# Example symbol="M:Prompt.Program.AskPasswordWithNullMask" project="Prompt" /?>
|
||||
|
||||
```text
|
||||
```text
|
||||
Enter password: _
|
||||
```
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
Title: Calendar
|
||||
Title: Calendar
|
||||
Order: 40
|
||||
RedirectFrom: calendar
|
||||
Description: "The **Calendar** is used to render a calendar to the terminal."
|
||||
|
Reference in New Issue
Block a user