* Allow setting the style of the default value in TextPrompt
Add property "DefaultValueStyle" to TextPrompt which allows setting the style in which the default value is rendered.
When no style is set, the value is displayed as green text, keeping the existing behavior.
* Allow setting the style in which a TextPrompt's choices are displayed
Add property "ChoicesStyle" to TextPrompt which allows setting the style in the prompt's choices are rendered.
When no style is set, choices are displayed as blue text, keeping the existing behavior.
* Introduce MarkupInterpolated and MarkupLineInterpolated extensions
These new methods enable easily writing markup with a nice and intuitive syntax without having to worry about escaping the markup.
```csharp
string input = args[0];
string output = Process(input);
AnsiConsole.MarkupLineInterpolated($"[blue]{input}[/] -> [green]{output}[/]");
```
The `Interpolated` suffix was inspired by the Entity Framework Core [FromSqlInterpolated][1] method.
[1]: https://docs.microsoft.com/en-us/ef/core/querying/raw-sql#passing-parameters
* Fixing whitespace to match file scoped namespaces
* Adding FromInterpolated helper to Markup widget
Allows automatic handling of interpolated strings to be used on the Markup widget. This would be helpful for people working with Tables and the Tree control who would not be using the MarkupInterpolated methods.
* Documentation for markup interpolated methods.
Co-authored-by: Cédric Luthi <cedric.luthi@gmail.com>
CommandOptions now has an IsHidden property that, when set to true, will cause the option to be hidden from the following cases:
- Help text using `-h|--help`
- Xml representations generated with the `cli xml` command
- Diagnostics displayed with the `cli explain` command
Hidden options can still be outputted with `cli explain` using the `--hidden` option that is also used to display hidden commands.
Fixes#631
The generic parameters were double escaped and would display as `[[T0,T1,TRet]]` instead of `[T0,T1,TRet]`. This is because the `builder.AppendWithStyle` method already escapes its value so the caller must not escape the passed value.
If the item contained escaped markup, after the call to RemoveMarkup
the string will contain unescaped markup (that the user explicitly had
escaped before) for those cases we need to escape all remaining markup.
When running on .NET Framework, the `Should_Report_Max_Remaining_Time_For_Extremely_Small_Progress` would intermittently fail with the following error:
```
task.RemainingTime
should be
10675199.02:48:05.4775807
but was
null
```
This is because it's possible that the two increment share the same timestamp thus making the `RemainingTime` null. To ensure the two increments don't share the same timestamp, we sleep for one millisecond.
Although I have only observed this issue on .NET Framework it would be possible that it occasionally also occur on .NET Core.
Since Spectre.Console targets .NET Standard 2.0 it makes sense to also run tests on .NET Framework (Windows only)
This makes two tests fail: `Should_Write_Exception_With_Inner_Exception` and `Should_Write_Exceptions_With_Generic_Type_Parameters_In_Callsite_As_Expected`.
Received (inner exception not handled):
```
System.InvalidOperationException: Something threw!System.InvalidOperationException: Throwing!
at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn
at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn
```
Verified:
```
System.InvalidOperationException: Something threw!
System.InvalidOperationException: Throwing!
at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn
at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn
at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn
at Spectre.Console.Tests.Unit.ExceptionTests.<>c.<Should_Write_Exception_With_Inner_Exception>b__3_0() in /xyz/ExceptionTests.cs:nn
at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn
```
Test rending a table with East Asia characters (Chinese, Japanese, Korean).
The verified text file may look weird, but it looks normal and correctly in Console (tested in Windows Terminal, Terminal.app in macOS Monterey)