Commit Graph

68 Commits

Author SHA1 Message Date
de847b90e4 Improve conversion error messages
When a conversion to an enum fails, list all the valid enum values in the error message.

Message before this commit:
> Error: heimday is not a valid value for DayOfWeek.

Message after this commit:
> Error: Failed to convert 'heimday' to DayOfWeek. Valid values are 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
2023-01-24 19:40:11 +01:00
7b9553dd22 Add possibility to set description and/or data for the default command (#1091) 2023-01-12 12:12:27 +00:00
54be64ec84 Add JSON text renderer (#1086)
* Add JsonText widget to render highlighted JSON

Closes #1051
2022-12-31 18:17:15 +00:00
3e6e0990c5 Automatically display default values of options in the help page (#1032)
Fixes #973
2022-12-28 20:28:41 +00:00
4a8a4ab048 Show help for default command (#953)
Shows help if the default command was called without any arguments but has required arguments.
This way it does not hinder execution of a default command without any required arguments.

When called without args:
- Default command with required params -> Show help
- Default command with required params and additional commands -> Show help including additional commands
- Default command without required params -> Execute command
2022-12-14 17:19:12 +00:00
b793482ebb Command line argument parsing improvements (#1048)
* Support negative numbers as command option values
* Support command line options before arguments
* POSIX-compliant handling of quotes (double and single, terminated and unterminated), whitespace, hyphens, and special characters (e.g. emojis)
2022-12-05 01:07:53 +01:00
f895bb175d modified tokenizer to not break on on ]]] at the end of a style 2022-12-01 22:32:32 +01:00
55c3f3b7a8 Figlet text should not pad on right side automatically 2022-11-15 12:36:49 +01:00
c3ec6a7363 Add Layout widget (#1041)
* Add width to panels
* Add height to panels
* Replace RenderContext with RenderOptions
* Remove exclusivity from alternative buffer
* Add Layout widget
* Add Align widget
2022-11-15 10:12:17 +01:00
7dce4af552 Add support for .NET 7.0 2022-11-10 12:01:13 +01:00
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