Add some AnsiConsole extensions and string manipulation. Support throwing CliCommandAbortException while constructing commands#77
Merged
darthsharp merged 7 commits intomainfrom Feb 1, 2026
Conversation
…ntroduce `AnsiConsoleStringExtensions` for string markup utilities.
… add nullability attributes, and update `DemoCliCommand` usage.
…mandAbortException` processing through a dedicated method.
…ons for `CliCommandAbortException` and add test for abort scenarios.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds convenience extension methods for working with Spectre.Console's AnsiConsole, including string markup helpers and multi-line writing methods. It also enhances error handling in the CLI framework by supporting CliCommandAbortException when thrown during command construction.
Changes:
- Added
AnsiConsoleStringExtensionswith markup helper methods for common colors and styles (red, green, yellow, blue, bold, italic, etc.) - Added
WriteLinesandMarkupLinesmethods toAnsiConsoleExtensionsfor writing multiple lines at once - Modified
DefaultCliHostto catch and handleCliCommandAbortExceptionthrown during command construction - Updated sample app to demonstrate the new
WriteLinesfunctionality
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| source/SysConsole/CreativeCoders.SysConsole.Core/AnsiConsoleStringExtensions.cs | New file with string extension methods for creating Spectre.Console markup |
| source/SysConsole/CreativeCoders.SysConsole.Core/AnsiConsoleExtensions.cs | Added WriteLines and MarkupLines methods for writing multiple lines to console |
| source/Cli/CreativeCoders.Cli.Hosting/DefaultCliHost.cs | Added handling for CliCommandAbortException during command construction, refactored duplicate abort handling code |
| tests/CreativeCoders.Cli.Tests/Hosting/DefaultCliHostTests.cs | Added test to verify CliCommandAbortException handling during command construction |
| samples/CliHostSampleApp/DemoCliCommand.cs | Updated to demonstrate new WriteLines extension method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…improved `CliCommandAbortException` handling.
…g[]` instead of `params IEnumerable<string>` for improved usability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.