Skip to content

Fix cli group duplicates shown if help is printed#75

Merged
darthsharp merged 2 commits intomainfrom
feature/fixcligroupduplicates
Jan 31, 2026
Merged

Fix cli group duplicates shown if help is printed#75
darthsharp merged 2 commits intomainfrom
feature/fixcligroupduplicates

Conversation

@darthsharp
Copy link
Copy Markdown
Contributor

No description provided.

- 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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread source/Cli/CreativeCoders.Cli.Hosting/DefaultCliHost.cs
…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.
@darthsharp darthsharp merged commit 6920c21 into main Jan 31, 2026
8 of 9 checks passed
@darthsharp darthsharp deleted the feature/fixcligroupduplicates branch January 31, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants