Skip to content

CLI: Add Reporter and outputwriter for structured CLI output w/ color and VT handling#40798

Open
dkbennett wants to merge 2 commits into
masterfrom
user/dkbennett/reporter
Open

CLI: Add Reporter and outputwriter for structured CLI output w/ color and VT handling#40798
dkbennett wants to merge 2 commits into
masterfrom
user/dkbennett/reporter

Conversation

@dkbennett

@dkbennett dkbennett commented Jun 13, 2026

Copy link
Copy Markdown
Member

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

See latest copilot summary.

Validation Steps Performed

  • All unit tests pass
  • Manual validation of the output behavior w/ various errors and cancellation.
  • Many automated code reviews run locally.

Copilot AI review requested due to automatic review settings June 13, 2026 01:31
@dkbennett dkbennett requested a review from a team as a code owner June 13, 2026 01:31

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 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 Reporter for level-gated output (Info/Warn/Error/Debug) with VT-aware formatting behavior.
  • Added OutputChannel/OutputWriter for 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.

Comment thread src/windows/wslc/core/OutputWriter.h Outdated
Comment thread src/windows/wslc/core/OutputWriter.cpp Outdated
Comment thread src/windows/wslc/core/Reporter.cpp Outdated
@dkbennett dkbennett marked this pull request as draft June 13, 2026 01:46
Copilot AI review requested due to automatic review settings June 13, 2026 05:59

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/windows/wslc/core/Main.cpp Outdated
Comment thread src/windows/wslc/core/Reporter.h Outdated
Comment thread src/windows/wslc/core/Reporter.cpp Outdated
Copilot AI review requested due to automatic review settings June 13, 2026 06:24

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/windows/wslc/core/OutputWriter.h
Comment thread src/windows/wslc/core/OutputWriter.cpp
Copilot AI review requested due to automatic review settings June 13, 2026 06:50

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/windows/wslc/core/Reporter.h Outdated
Comment thread src/windows/wslc/core/OutputWriter.cpp
Comment thread src/windows/wslc/core/Reporter.cpp Outdated
Copilot AI review requested due to automatic review settings June 13, 2026 07:14

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread src/windows/wslc/core/Reporter.h
Comment thread src/windows/wslc/core/Reporter.h Outdated
Comment thread test/windows/wslc/WSLCCLIReporterUnitTests.cpp
Comment thread src/windows/wslc/core/Reporter.cpp Outdated
Comment thread src/windows/wslc/core/OutputWriter.h
@dkbennett dkbennett force-pushed the user/dkbennett/reporter branch from ff1bee9 to 2d1a14f Compare June 13, 2026 07:32
Copilot AI review requested due to automatic review settings June 13, 2026 08:10

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

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

@dkbennett dkbennett marked this pull request as ready for review June 13, 2026 09:35
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