[WSLC] Add 'wslc version' subcommand#14547
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
Added this, @AmelBawa-msft, PTAL |
VersionCommand::ExecuteInternal to avoid build issues
9afcebe to
bf04c87
Compare
- Use Localization::WSLCCLI_VersionDesc/LongDesc instead of hard-coded strings; add entries to en-US Resources.resw - Centralize version printing in VersionCommand::PrintVersion(); reuse from RootCommand --version flag - Drop 'v' prefix from version output per OneBlue's feedback - Add 'version' entry to E2E GetAvailableCommands() to fix WSLCE2E_HelpCommand and WSLCE2E_InvalidCommand_DisplaysErrorMessage Co-Authored-By: Pooja Trivedi
…ptrivedi/cli-version
Localization::WSLCCLI_VersionDesc() and WSLCCLI_VersionLongDesc() live in wsl::shared::Localization. Without this using directive the compiler cannot resolve the unqualified Localization:: references in VersionCommand.cpp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ptrivedi/cli-version
|
Hey @ptrivedi 👋 — Following up on this PR. CI is passing, but there are 5 unresolved review threads:
Could you take a look at addressing these when you get a chance? Thanks! |
Review threads have been resolved. Will merge this. |
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