-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[WSLC] Add 'wslc version' subcommand #14547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/wsl-for-apps
Are you sure you want to change the base?
Changes from all commits
3e4738a
a81125a
660b493
70b1e83
bf04c87
86a999c
33ca5d1
f8fa60f
182b0d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VersionCommand.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of the version command. | ||
|
|
||
| --*/ | ||
| #include "VersionCommand.h" | ||
|
|
||
| using namespace wsl::windows::wslc::execution; | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| std::wstring VersionCommand::ShortDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VersionDesc(); | ||
| } | ||
|
|
||
| std::wstring VersionCommand::LongDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VersionLongDesc(); | ||
| } | ||
|
|
||
| void VersionCommand::PrintVersion() | ||
| { | ||
| wsl::windows::common::wslutil::PrintMessage(std::format(L"{} {}", s_ExecutableName, WSL_PACKAGE_VERSION)); | ||
| } | ||
|
|
||
| void VersionCommand::ExecuteInternal(CLIExecutionContext& context) const | ||
| { | ||
| UNREFERENCED_PARAMETER(context); | ||
| PrintVersion(); | ||
| } | ||
|
Comment on lines
+34
to
+38
|
||
| } // namespace wsl::windows::wslc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VersionCommand.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Declaration of the VersionCommand. | ||
|
|
||
| --*/ | ||
| #pragma once | ||
| #include "Command.h" | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| struct VersionCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"version"; | ||
| VersionCommand(const std::wstring& parent) : Command(CommandName, parent) | ||
| { | ||
| } | ||
| static void PrintVersion(); | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| protected: | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
| } // namespace wsl::windows::wslc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,11 @@ class WSLCE2EGlobalTests | |
| RunWslcAndVerify(L"INVALID_CMD", {.Stdout = GetHelpMessage(), .Stderr = L"Unrecognized command: 'INVALID_CMD'\r\n", .ExitCode = 1}); | ||
| } | ||
|
|
||
| TEST_METHOD(WSLCE2E_VersionCommand) | ||
| { | ||
| WSL2_TEST_ONLY(); | ||
| RunWslcAndVerify(L"version", {.Stdout = GetVersionMessage(), .Stderr = L"", .ExitCode = 0}); | ||
| } | ||
|
Comment on lines
+54
to
+58
|
||
| TEST_METHOD(WSLCE2E_Session_DefaultElevated) | ||
| { | ||
| WSL2_TEST_ONLY(); | ||
|
|
@@ -400,6 +405,11 @@ class WSLCE2EGlobalTests | |
| return output.str(); | ||
| } | ||
|
|
||
| std::wstring GetVersionMessage() const | ||
| { | ||
| return std::format(L"wslc {}\r\n", WSL_PACKAGE_VERSION); | ||
| } | ||
|
|
||
| std::wstring GetDescription() const | ||
| { | ||
| return L"WSLC is the Windows Subsystem for Linux Container CLI tool. It enables management and interaction with WSL " | ||
|
|
@@ -435,6 +445,7 @@ class WSLCE2EGlobalTests | |
| {L"save", Localization::WSLCCLI_ImageSaveDesc()}, | ||
| {L"start", Localization::WSLCCLI_ContainerStartDesc()}, | ||
| {L"stop", Localization::WSLCCLI_ContainerStopDesc()}, | ||
| {L"version", Localization::WSLCCLI_VersionDesc()}, | ||
| }; | ||
|
|
||
| size_t maxLen = 0; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.