Fix cli group duplicates shown if help is printed#75
Merged
darthsharp merged 2 commits intomainfrom Jan 31, 2026
Merged
Conversation
- Introduced `CliCommandAbortException` for improved error management. - Added `AssemblyScanResult` for grouping commands and attributes. - Updated help command behavior to support `CommandOrArgument` option. - Simplified command group handling with "demo" namespace constant. - Enhanced `CliCommandStore` to prevent duplicate group nodes. - Modified sample commands for consistency with new group structure. - Added unit test to validate non-duplicated group behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where CLI command groups were being duplicated in the root nodes list when help was printed. The main fix adds a duplicate check before adding group nodes to the root collection.
Changes:
- Added duplicate prevention logic in CliCommandStore to avoid adding the same group node to root nodes multiple times
- Added a new CliCommandAbortException class with handling in DefaultCliHost for custom command abort scenarios
- Extracted AssemblyScanResult class to a separate file for better code organization
- Refactored sample app to use a dedicated DemoCommandGroup class and reorganized command paths
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| source/Cli/CreativeCoders.Cli.Hosting/Commands/Store/CliCommandStore.cs | Added Contains check to prevent duplicate group nodes in root collection |
| tests/CreativeCoders.Cli.Tests/Hosting/Commands/CliCommandStoreTests.cs | Added test to verify no duplicate groups are created |
| source/Cli/CreativeCoders.Cli.Hosting/Exceptions/CliCommandAbortException.cs | New exception class for command abort scenarios |
| source/Cli/CreativeCoders.Cli.Hosting/DefaultCliHost.cs | Added exception handler for CliCommandAbortException |
| source/Cli/CreativeCoders.Cli.Hosting/Commands/AssemblyScanResult.cs | Extracted class to separate file |
| source/Cli/CreativeCoders.Cli.Hosting/Commands/AssemblyCommandScanner.cs | Removed inline AssemblyScanResult class definition |
| samples/CliHostSampleApp/DemoCommandGroup.cs | New file with group constant and assembly attribute |
| samples/CliHostSampleApp/DemoCliCommandWithOptions.cs | Updated command path from ["demo", "do", "something"] to ["demo", "list"] |
| samples/CliHostSampleApp/DemoCliCommand.cs | Moved group attributes and refactored to use DemoCommandGroup.Name constant |
| samples/CliHostSampleApp/Program.cs | Changed help configuration from HelpCommandKind.Command to CommandOrArgument |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ption` scenarios: - Introduced `RunAsync_WhenCommandWithAbortException_ExecutesAndReturnsExceptionResult` test with various exception configurations. - Added `DummyCommandWithErrorAbortException`, `DummyCommandWithNoneErrorAbortException`, and `DummyCommandWithoutPrintErrorAbortException` test cases. - Enhanced console output testing with custom `CheckConsoleOutput` utility.
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.