Skip to content

CLI: Initial support for version format option#40238

Open
AmelBawa-msft wants to merge 5 commits intofeature/wsl-for-appsfrom
user/amelbawa/version-format
Open

CLI: Initial support for version format option#40238
AmelBawa-msft wants to merge 5 commits intofeature/wsl-for-appsfrom
user/amelbawa/version-format

Conversation

@AmelBawa-msft
Copy link
Copy Markdown

@AmelBawa-msft AmelBawa-msft commented Apr 18, 2026

Summary of the Pull Request

  • Initial support for version format option

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

Validation Steps Performed

Copilot AI review requested due to automatic review settings April 18, 2026 00:05
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

Adds initial wslc version command support for selectable output formats (table/json), wiring version collection into the CLI execution context and exposing it via a new task/service/model flow.

Changes:

  • Introduces VersionService + VersionInfo model to provide client/server version data.
  • Adds VersionTasks to emit version output as table (default) or JSON via --format.
  • Updates VersionCommand execution and adds an E2E help test for wslc version.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/windows/wslc/e2e/WSLCE2EVersionTests.cpp Adds E2E test coverage for version --help.
src/windows/wslc/tasks/VersionTasks.h Declares tasks for fetching and rendering version info.
src/windows/wslc/tasks/VersionTasks.cpp Implements format selection and output for version.
src/windows/wslc/services/VersionService.h Declares service API for version info/string.
src/windows/wslc/services/VersionService.cpp Implements version string + static version info instance.
src/windows/wslc/services/VersionModel.h Adds ClientVersion/ServerVersion/VersionInfo model + JSON support.
src/windows/wslc/core/ExecutionContextData.h Adds Data::Version storage mapping to the execution context.
src/windows/wslc/commands/VersionCommand.h Switches VersionCommand to expose arguments (format).
src/windows/wslc/commands/VersionCommand.cpp Wires version execution through the new tasks and adds --format.
src/windows/wslc/commands/RootCommand.cpp Routes --version to VersionService::GetVersionString().

Comment thread test/windows/wslc/e2e/WSLCE2EVersionTests.cpp
Comment thread src/windows/wslc/services/VersionModel.h
Comment thread src/windows/wslc/services/VersionModel.h
Comment thread src/windows/wslc/commands/VersionCommand.cpp
Comment thread src/windows/wslc/tasks/VersionTasks.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EVersionTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EVersionTests.cpp
@AmelBawa-msft AmelBawa-msft marked this pull request as ready for review April 18, 2026 03:44
@AmelBawa-msft AmelBawa-msft requested a review from a team as a code owner April 18, 2026 03:44
Copilot AI review requested due to automatic review settings April 18, 2026 03:44
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

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

Comment thread src/windows/wslc/services/VersionService.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EVersionTests.cpp
@AmelBawa-msft
Copy link
Copy Markdown
Author

@copilot fix the VersionCommand_HasNoArguments test method in WSLCCLICommandUnitTests.cpp, in this PR I added one argument to the version command.

…dded in PR

Agent-Logs-Url: https://github.com/microsoft/WSL/sessions/309f2df8-2ce9-4f99-8b04-2d5c7fbeb50c

Co-authored-by: AmelBawa-msft <104940545+AmelBawa-msft@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

@copilot fix the VersionCommand_HasNoArguments test method in WSLCCLICommandUnitTests.cpp, in this PR I added one argument to the version command.

Fixed in commit 36d00ce. Renamed the test to VersionCommand_HasFormatArgument and updated the expected counts: GetArguments().size() now expects 1 (the --format arg) and GetAllArguments().size() now expects 2 (--format + auto-added --help).

Copy link
Copy Markdown
Member

@dkbennett dkbennett left a comment

Choose a reason for hiding this comment

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

Overall structure and approach looks good, I only have issues with the table output, which looks like it needs loc for table format and should use the same table output as other commands. Also a note about the help change that will cause a test failure.

std::wstringstream options;
options << L"The following options are available:\r\n"
<< L" --format Output formatting (json or table) (Default: table)\r\n"
<< L" -h,--help Shows help about the selected command\r\n"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will be a test failure now that help flag has been changed to -?

}
case FormatType::Table:
{
PrintMessage(MultiByteToWide(versionInfo.ToString()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should use the table output format all the other tables use.

{
std::stringstream ss;
ss << "Server:\n";
ss << WSLC_VERSION_ROW(" Linux kernel", Kernel);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These strings should be loc'd for table output in the CLI.

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.

4 participants