Skip to content

[WSLC] Add 'wslc version' subcommand#14547

Open
ptrivedi wants to merge 7 commits intofeature/wsl-for-appsfrom
user/ptrivedi/cli-version
Open

[WSLC] Add 'wslc version' subcommand#14547
ptrivedi wants to merge 7 commits intofeature/wsl-for-appsfrom
user/ptrivedi/cli-version

Conversation

@ptrivedi
Copy link
Copy Markdown

@ptrivedi ptrivedi commented Mar 26, 2026

Summary of the Pull Request

Adds a version subcommand to the WSLC CLI so users can run wslc version in addition to the existing wslc --version flag. This follows the subcommand pattern used by other WSLC commands.

Changes

  • commands/VersionCommand.h / commands/VersionCommand.cpp — new VersionCommand that prints wslc v<version>
  • commands/RootCommand.cpp — registers VersionCommand as a subcommand of the root

Tests

  • CommandLineTestCases.h — parsing test cases for wslc version, wslc version --help, and invalid usage
  • WSLCCLICommandUnitTests.cpp — unit tests verifying command name, no subcommands, no extra arguments, and presence in root command's subcommand list

Validation Steps Performed

Verified manually that wslc version prints the version string identically to wslc --version.

TODO

  • Discuss and decide with the team whether wslc --version can be removed now that wslc version exists.

🤖 Generated with Claude Code

Adds a 'version' subcommand to the WSLC CLI as an alternative to the
existing '--version' flag, following the subcommand pattern used by
other WSLC commands. Includes unit tests for command structure and
command-line parsing.

Co-authored-by: Pooja Trivedi <trivedipooja@microsoft.com>
Co-Authored-By: Claude Sonnet 4.6
@ptrivedi ptrivedi requested a review from a team as a code owner March 26, 2026 20:06
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@ptrivedi ptrivedi requested review from AmelBawa-msft and dkbennett and removed request for damanm24 and jstarks March 26, 2026 20:08
@ptrivedi ptrivedi changed the base branch from master to feature/wsl-for-apps March 26, 2026 20:11
@ptrivedi ptrivedi requested a review from a team as a code owner March 26, 2026 20:11
@benhillis benhillis requested a review from Copilot March 26, 2026 20:27
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 5 out of 5 changed files in this pull request and generated no new comments.

@AmelBawa-msft
Copy link
Copy Markdown

LGTM! I suspect the E2E test will fail for WSLCE2EGlobalTests class because we need to update the help message and potentially add some E2E tests for version (e.g. ensure returns exit code 0, the expected version in stdout, empty string in stderr).

e.g.

RunWslcAndVerify("version", { .Stdout = std::format(L"{} v{}", ..., ...),  .Stderr = L"",  .ExitCode = 0});

…dition

Update expected help output in WSLCE2EGlobalTests to include the newly
added 'version' subcommand, fixing WSLCE2E_HelpCommand and
WSLCE2E_InvalidCommand_DisplaysErrorMessage test failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 27, 2026 18:27
@ptrivedi ptrivedi marked this pull request as draft March 27, 2026 18:28
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 6 out of 6 changed files in this pull request and generated 1 comment.

@ptrivedi ptrivedi marked this pull request as ready for review March 29, 2026 03:15
Copilot AI review requested due to automatic review settings March 29, 2026 03:15
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 6 out of 6 changed files in this pull request and generated 2 comments.

- Add WSLCE2E_VersionCommand E2E test in WSLCE2EGlobalTests verifying
  stdout, empty stderr, and exit code for 'wslc version'
- Add assertion to VersionCommand_HasNoArguments unit test to verify
  only the auto-added --help argument is present

Authored-By: Pooja Trivedi <trivedipooja@microsoft.com>
Co-Authored-By: Claude Sonnet 4.6
@ptrivedi ptrivedi force-pushed the user/ptrivedi/cli-version branch from 309d934 to 70b1e83 Compare March 29, 2026 04:04
@ptrivedi
Copy link
Copy Markdown
Author

LGTM! I suspect the E2E test will fail for WSLCE2EGlobalTests class because we need to update the help message and potentially add some E2E tests for version (e.g. ensure returns exit code 0, the expected version in stdout, empty string in stderr).

e.g.

RunWslcAndVerify("version", { .Stdout = std::format(L"{} v{}", ..., ...),  .Stderr = L"",  .ExitCode = 0});

Added this, @AmelBawa-msft, PTAL

Copilot AI review requested due to automatic review settings March 29, 2026 04:10
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 6 out of 6 changed files in this pull request and generated no new comments.

VersionCommand::ExecuteInternal to avoid build issues
@ptrivedi ptrivedi force-pushed the user/ptrivedi/cli-version branch from 9afcebe to bf04c87 Compare March 29, 2026 04:23
Copilot AI review requested due to automatic review settings March 29, 2026 04:25
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 6 out of 6 changed files in this pull request and generated no new comments.

void VersionCommand::ExecuteInternal(CLIExecutionContext& context) const
{
UNREFERENCED_PARAMETER(context);
wsl::windows::common::wslutil::PrintMessage(std::format(L"{} v{}", s_ExecutableName, WSL_PACKAGE_VERSION));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I recommend dropping the v here to make parsing easier for callers

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