[WSLC] Add 'wslc version' subcommand#14547
Open
ptrivedi wants to merge 7 commits intofeature/wsl-for-appsfrom
Open
[WSLC] Add 'wslc version' subcommand#14547ptrivedi wants to merge 7 commits intofeature/wsl-for-appsfrom
ptrivedi wants to merge 7 commits intofeature/wsl-for-appsfrom
Conversation
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
|
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 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>
- 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
309d934 to
70b1e83
Compare
Author
Added this, @AmelBawa-msft, PTAL |
VersionCommand::ExecuteInternal to avoid build issues
9afcebe to
bf04c87
Compare
OneBlue
reviewed
Mar 30, 2026
| void VersionCommand::ExecuteInternal(CLIExecutionContext& context) const | ||
| { | ||
| UNREFERENCED_PARAMETER(context); | ||
| wsl::windows::common::wslutil::PrintMessage(std::format(L"{} v{}", s_ExecutableName, WSL_PACKAGE_VERSION)); |
Collaborator
There was a problem hiding this comment.
nit: I recommend dropping the v here to make parsing easier for callers
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
Adds a
versionsubcommand to the WSLC CLI so users can runwslc versionin addition to the existingwslc --versionflag. This follows the subcommand pattern used by other WSLC commands.Changes
commands/VersionCommand.h/commands/VersionCommand.cpp— newVersionCommandthat printswslc v<version>commands/RootCommand.cpp— registersVersionCommandas a subcommand of the rootTests
CommandLineTestCases.h— parsing test cases forwslc version,wslc version --help, and invalid usageWSLCCLICommandUnitTests.cpp— unit tests verifying command name, no subcommands, no extra arguments, and presence in root command's subcommand listValidation Steps Performed
Verified manually that
wslc versionprints the version string identically towslc --version.TODO
wslc --versioncan be removed now thatwslc versionexists.🤖 Generated with Claude Code