CLI: Add Reporter and outputwriter for structured CLI output w/ color and VT handling#40798
Open
dkbennett wants to merge 2 commits into
Open
CLI: Add Reporter and outputwriter for structured CLI output w/ color and VT handling#40798dkbennett wants to merge 2 commits into
dkbennett wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new structured output pipeline for the wslc CLI by adding a Reporter abstraction (level-aware output) backed by an OutputWriter/OutputChannel implementation (buffered, atomic flush, optional VT color handling). It integrates the reporter into the CLI execution context and updates Main.cpp error/cancellation reporting to use it, along with unit tests and a new localized cancellation string.
Changes:
- Added
Reporterfor level-gated output (Info/Warn/Error/Debug) with VT-aware formatting behavior. - Added
OutputChannel/OutputWriterfor buffered output accumulation and atomic flush semantics with optional color filtering and SGR reset. - Integrated reporter into the CLI execution context, updated main cancellation/error paths, added unit tests, and added a new en-US localization string.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/wslc/WSLCCLIReporterUnitTests.cpp | Adds unit tests covering routing, VT/color filtering, flush lifecycle, clone semantics, and level gating. |
| src/windows/wslc/core/Reporter.h | Declares the Reporter interface (levels, routing, cloning, console width). |
| src/windows/wslc/core/Reporter.cpp | Implements level gating, formatting selection, and stdout/stderr routing behavior. |
| src/windows/wslc/core/OutputWriter.h | Declares OutputChannel and OutputWriter (buffering + VT/color controls). |
| src/windows/wslc/core/OutputWriter.cpp | Implements buffered flush, VT sequence handling, and OutputChannel console/FILE* backends. |
| src/windows/wslc/core/Main.cpp | Enables VT mode on stdout and switches cancellation/error reporting to use context.Output. |
| src/windows/wslc/core/CLIExecutionContext.h | Adds Reporter Output to the execution context for shared CLI output. |
| localization/strings/en-US/Resources.resw | Adds WSLCCLI_OperationCancelled string for localized cancellation messaging. |
ff1bee9 to
2d1a14f
Compare
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.
Summary of the Pull Request
Introduces a centralized Reporter / OutputWriter system for structured, level-aware console output in wslc. This provides a consistent output pipeline with VT color formatting, level-based routing, and automatic SGR reset — laying the groundwork for richer CLI output and level adjustments, enabling debug output and updating error messages in main to use this for output.
Other code can be converted to use reporter as needed or in a future update, didn't want massive churn with this introduction.
Added tests are unit tests for fast execution and coverage of many edge cases and scenarios.
PR Checklist
Detailed Description of the Pull Request / Additional comments
See latest copilot summary.
Validation Steps Performed