Commit Graph

58 Commits

Author SHA1 Message Date
6a4d8c8f30 Add culture option to TypeConverterHelper, TextPrompt and AnsiConsole (#1014)
* Add culture option to TypeConverterHelper, TextPrompt and AnsiConsole

* Add IHasCulture interface
2022-10-15 11:19:06 +02:00
f6a7c96413 Create Test, allow for conditional trim 2022-10-13 20:42:23 +02:00
a91a3c12ad Remove trimming 2022-10-13 20:42:23 +02:00
999c59909b Fix @ being used in figlet font 2022-10-01 17:12:11 +02:00
fd8d271a10 chore: Update dependency Microsoft.NET.Test.Sdk to v17.3.2 2022-10-01 17:10:10 +02:00
4f0ec87522 Allow selections to wrap around 2022-09-26 23:32:57 -04:00
eb02c3d534 Custom mask for secret (#970)
* 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
2022-09-26 20:34:41 +02:00
088db165ed Added tests on backward direction of autocomplete 2022-09-19 08:58:45 +02:00
2bd1383cbe Fixed punctuation 2022-08-29 08:54:30 +02:00
00a9ba325e restructured MarkupTokenizer a bit. 2022-08-29 08:54:30 +02:00
540bc1307c fixed warning 2022-08-29 08:54:30 +02:00
a6618f762c Modified MarkupTokenizer
So escaped markup in markup is valid.
2022-08-29 08:54:30 +02:00
638149f44b fixed punctuation in exception 2022-08-29 08:54:30 +02:00
0d72b94f9c added some breaking unit tests 2022-08-29 08:54:30 +02:00
0d19ccd8a6 (#916) fixed missing call to Validate when using CommandConstructorBinder 2022-08-18 12:03:11 +02:00
78d841e3dc Added command description to command help message (#920) 2022-08-17 16:59:08 +02:00
3a7b8aa1d2 chore: Update dependency xunit to v2.4.2 2022-08-03 15:04:26 +02:00
dc93edef15 Remove the 'net50' TFM
Also updates all dependencies to the latest version.

Closes #829
2022-07-02 11:18:34 +02:00
36ca22ffac Move Spectre.Console.Cli to it's own package 2022-05-15 00:09:52 +02:00
38d9386e00 Add option to configure the style of the choices list and the default value in TextPrompt (#681)
* 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.
2022-03-27 19:38:01 +02:00
1d8154f9b0 Introduce MarkupInterpolated and MarkupLineInterpolated extensions (#761)
* 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>
2022-03-22 22:34:25 +01:00
eb4a7d3bf4 Add support for alignment 2022-02-23 09:06:51 -05:00
5e41a2f505 Add support for styling segments 2022-02-23 09:06:51 -05:00
66fc949e2a Initial work on TextPath widget 2022-02-20 23:26:04 -05:00
74a2e10ff0 Making tuples pretty too 2022-02-04 10:30:09 +01:00
78958aae27 Adding better type names for return types and parameters
Uses the typenamehelper from Ben.Demystifer to help break down things like generic lists into their actual type display name.
2022-02-04 10:30:09 +01:00
52c1d9122b Add global usings (#668)
* Use global usings

* Fix namespace declarations for test projects
2021-12-23 16:50:31 +01:00
ec1188b837 Use file scoped namespace declarations 2021-12-22 08:51:17 -05:00
37f661a963 fix: table title's first letter is getting capitalized by default (#652)
fix for #638
2021-12-07 13:03:30 +01:00
55633b59fa (#645) Ordered CommandArguments by position
in CommandModelValidator
2021-12-02 11:15:25 +01:00
fd4b96944e Add support for alternate screen buffers
Closes #250
2021-11-30 12:13:14 -05:00
2e5d18fa78 Added the ability to hide CommandOptions. (#642)
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
2021-11-29 23:16:54 +01:00
168f35202d Fix exception formatting for generic methods (#639)
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.
2021-11-26 10:23:20 +01:00
8fed3bc575 Fix type conversion in the default pair deconstructor implementation (#618)
The code using the TypeConverter was written backwards (using `ConvertTo` instead of `ConvertFrom` and would thus throw an exception.
2021-11-22 15:07:58 +01:00
19eb273813 Fix typo in PairDeconstructor class name
PairDeconstuctor → PairDeconstructor (was missing an 'r')

Keeping `PairDeconstuctor` and marking it as obsolete since it's a public type.
2021-11-14 10:36:16 +01:00
48df9cf68b (#555) added TypeRegistrarBaseTests
as a very simple test harness to test implementations of
ITypeRegistrar / ITypeResolver
2021-11-14 01:19:27 +01:00
e86f9d3c5a Allow color numbers in markup expressions
Closes #614
2021-11-09 09:32:50 -05:00
ba4b7b97f8 Escape any Markup when displaying selected prompt items
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.
2021-11-02 22:56:54 +01:00
c5c1852fc3 (#606) added ExceptionHandler to ICommandAppSettings
So exceptions can be handled in Spectre.Console.Cli.
Also, some documentation was added.
2021-10-30 01:41:29 +02:00
949f35defd (#502) Added GetParent and GetParents to MultiSelectionPrompt
So it it possible to find the parent(s) of a given item.
2021-10-30 00:05:16 +02:00
d02c9e552e Add net6.0 TFM (#603)
Closes #602
2021-10-29 21:05:17 +02:00
2a3763cdc7 Prove that remaining args works in strict mode
Closes #496
2021-10-05 09:34:08 -04:00
fa15389158 Add support custom max value for barcharts (#545) 2021-10-05 00:49:09 +02:00
e3dfe23b59 Work done to allow user to update table cell. (#546) 2021-09-27 13:03:45 +02:00
49e8a980a7 Removed the additional registration of ICommand 2021-09-18 23:19:34 +02:00
ffd24ec451 Fix intermittent test failure
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.
2021-08-30 11:08:24 +02:00
bf95564ebb Make tests run on .NET Framework 4.8
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
```
2021-08-30 11:08:24 +02:00
7276e11ecc Add a test for rendering table with EA characters
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)
2021-08-24 16:45:30 +02:00
e169df6303 Add support for manipulating individual table rows
Closes #500
2021-08-14 23:35:07 +02:00
170901f584 Adds additional check that analyzer is within a method
Resolve #487
2021-07-19 22:31:25 +02:00