Skip to content

Implement dependency injection for CLI commands - #114

Merged
xping-admin merged 1 commit into
mainfrom
feat/add-di-hosting-foundation
Aug 10, 2026
Merged

Implement dependency injection for CLI commands#114
xping-admin merged 1 commit into
mainfrom
feat/add-di-hosting-foundation

Conversation

@xping-admin

Copy link
Copy Markdown
Collaborator

Introduce a dependency injection framework for managing CLI commands and I/O operations, enhancing modularity and testability. This change includes the addition of a ConsoleIO class for I/O management and a factory for creating ILocalRunStore instances.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a DI-based composition root for the xping CLI so command implementations and I/O streams can be constructor-injected, improving modularity and testability while keeping the CLI’s stdout/stderr test seams intact.

Changes:

  • Add a per-invocation IHost composition root and resolve CLI commands from DI instead of static helpers/closures.
  • Introduce ConsoleIO to carry per-invocation TextWriter/TextReader through DI and a LocalRunStoreFactory to create ILocalRunStore instances with consistent logging wiring.
  • Update documentation references to the shared XpingVersion type and add the hosting dependency to the CLI project.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Xping.Sdk.Shared/XpingVersion.cs Updates XML doc example to reference XpingVersion.Current.
src/Xping.Cli/Xping.Cli.csproj Adds Microsoft.Extensions.Hosting to support HostApplicationBuilder DI composition.
src/Xping.Cli/Services/LocalRunStoreFactory.cs Adds a factory abstraction to create ILocalRunStore instances per command invocation.
src/Xping.Cli/Program.cs Builds/disposes an IHost per run and resolves command handlers via DI.
src/Xping.Cli/Hosting/ServiceCollectionExtensions.cs Registers CLI services (I/O, store factory, commands) into DI.
src/Xping.Cli/Hosting/ConsoleIO.cs Adds DI-carried per-invocation I/O streams for commands.
src/Xping.Cli/Commands/WhereCommand.cs Converts to DI-resolved command with injected store factory + I/O.
src/Xping.Cli/Commands/ReportCommand.cs Converts to DI-resolved command with injected store factory + I/O.
src/Xping.Cli/Commands/ClearCommand.cs Converts to DI-resolved command with injected store factory + I/O.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/Xping.Cli/Commands/ClearCommand.cs 66.66% <100.00%> (+3.80%) ⬆️
src/Xping.Cli/Commands/ReportCommand.cs 84.54% <100.00%> (+0.14%) ⬆️
src/Xping.Cli/Commands/WhereCommand.cs 83.33% <100.00%> (+0.98%) ⬆️
src/Xping.Cli/Hosting/ConsoleIO.cs 100.00% <100.00%> (ø)
...c/Xping.Cli/Hosting/ServiceCollectionExtensions.cs 100.00% <100.00%> (ø)
src/Xping.Cli/Program.cs 97.81% <100.00%> (+0.08%) ⬆️
src/Xping.Cli/Services/LocalRunStoreFactory.cs 100.00% <100.00%> (ø)
src/Xping.Sdk.Shared/XpingVersion.cs 50.00% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xping-admin
xping-admin merged commit 9a247e8 into main Aug 10, 2026
3 checks passed
@xping-admin
xping-admin deleted the feat/add-di-hosting-foundation branch August 10, 2026 13:15
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