-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CLI: Initial support for volume commands #40139
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
Open
AmelBawa-msft
wants to merge
14
commits into
feature/wsl-for-apps
Choose a base branch
from
user/amelbawa/volume
base: feature/wsl-for-apps
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b851ae9
Init volume command
AmelBawa-msft 89c64d5
WIP
AmelBawa-msft 861c013
Merge branch 'feature/wsl-for-apps' of https://github.com/microsoft/w…
AmelBawa-msft 2fa9ce8
Create
AmelBawa-msft 5029cf8
CLang format
AmelBawa-msft 506a52c
Volume command
AmelBawa-msft 02ba889
Added E2E tests
AmelBawa-msft f1f47fc
Clang format
AmelBawa-msft 7917b2e
Resolve copilot comment
AmelBawa-msft 8783457
Revert test in run/create
AmelBawa-msft 49efe4f
Rename delete to remove
AmelBawa-msft 21849d3
Resolve copilot comment
AmelBawa-msft a5a3dbf
Resolve copilot comment
AmelBawa-msft 912a4c5
Fix e2e tests
AmelBawa-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VolumeCommand.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of command execution logic. | ||
|
|
||
| --*/ | ||
| #include "CLIExecutionContext.h" | ||
| #include "VolumeCommand.h" | ||
|
|
||
| using namespace wsl::windows::wslc::execution; | ||
| using namespace wsl::shared; | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| // Volume Root Command | ||
| std::vector<std::unique_ptr<Command>> VolumeCommand::GetCommands() const | ||
| { | ||
| std::vector<std::unique_ptr<Command>> commands; | ||
| commands.push_back(std::make_unique<VolumeCreateCommand>(FullName())); | ||
| commands.push_back(std::make_unique<VolumeRemoveCommand>(FullName())); | ||
| commands.push_back(std::make_unique<VolumeInspectCommand>(FullName())); | ||
| commands.push_back(std::make_unique<VolumeListCommand>(FullName())); | ||
| return commands; | ||
| } | ||
|
|
||
| std::vector<Argument> VolumeCommand::GetArguments() const | ||
| { | ||
| return {}; | ||
| } | ||
|
|
||
| std::wstring VolumeCommand::ShortDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeCommandDesc(); | ||
| } | ||
|
|
||
| std::wstring VolumeCommand::LongDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeCommandLongDesc(); | ||
| } | ||
|
|
||
| void VolumeCommand::ExecuteInternal(CLIExecutionContext& context) const | ||
| { | ||
| OutputHelp(); | ||
| } | ||
| } // namespace wsl::windows::wslc |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VolumeCommand.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Declaration of command classes and interfaces. | ||
|
|
||
| --*/ | ||
| #pragma once | ||
| #include "Command.h" | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| // Root Volume Command | ||
| struct VolumeCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"volume"; | ||
| VolumeCommand(const std::wstring& parent) : Command(CommandName, parent) | ||
| { | ||
| } | ||
| std::vector<Argument> GetArguments() const override; | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| std::vector<std::unique_ptr<Command>> GetCommands() const override; | ||
|
|
||
| protected: | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
|
|
||
| // Create Command | ||
| struct VolumeCreateCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"create"; | ||
| VolumeCreateCommand(const std::wstring& parent) : Command(CommandName, parent) | ||
| { | ||
| } | ||
| std::vector<Argument> GetArguments() const override; | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| protected: | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
|
|
||
| // Remove Command | ||
| struct VolumeRemoveCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"remove"; | ||
| VolumeRemoveCommand(const std::wstring& parent) : Command(CommandName, {L"delete", L"rm"}, parent) | ||
| { | ||
| } | ||
| std::vector<Argument> GetArguments() const override; | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| protected: | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
|
|
||
| // Inspect Command | ||
| struct VolumeInspectCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"inspect"; | ||
| VolumeInspectCommand(const std::wstring& parent) : Command(CommandName, parent) | ||
| { | ||
| } | ||
| std::vector<Argument> GetArguments() const override; | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| protected: | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
|
|
||
| // List Command | ||
| struct VolumeListCommand final : public Command | ||
| { | ||
| constexpr static std::wstring_view CommandName = L"list"; | ||
| VolumeListCommand(const std::wstring& parent) : Command(CommandName, {L"ls"}, parent) | ||
| { | ||
| } | ||
| std::vector<Argument> GetArguments() const override; | ||
| std::wstring ShortDescription() const override; | ||
| std::wstring LongDescription() const override; | ||
|
|
||
| protected: | ||
| void ValidateArgumentsInternal(const ArgMap& execArgs) const override; | ||
| void ExecuteInternal(CLIExecutionContext& context) const override; | ||
| }; | ||
| } // namespace wsl::windows::wslc |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VolumeCreateCommand.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of command execution logic. | ||
|
|
||
| --*/ | ||
|
|
||
| #include "VolumeCommand.h" | ||
| #include "CLIExecutionContext.h" | ||
| #include "SessionTasks.h" | ||
| #include "VolumeTasks.h" | ||
| #include "Task.h" | ||
|
|
||
| using namespace wsl::windows::wslc::execution; | ||
| using namespace wsl::windows::wslc::task; | ||
| using namespace wsl::shared; | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| // Volume Create Command | ||
| std::vector<Argument> VolumeCreateCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::Create(ArgType::VolumeName, true), | ||
| Argument::Create(ArgType::Driver), | ||
| Argument::Create(ArgType::Options, false, NO_LIMIT), | ||
| Argument::Create(ArgType::Session), | ||
| }; | ||
| } | ||
|
|
||
| std::wstring VolumeCreateCommand::ShortDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeCreateDesc(); | ||
| } | ||
|
|
||
| std::wstring VolumeCreateCommand::LongDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeCreateLongDesc(); | ||
| } | ||
|
|
||
| void VolumeCreateCommand::ExecuteInternal(CLIExecutionContext& context) const | ||
| { | ||
| context << CreateSession // | ||
| << CreateVolume; | ||
| } | ||
| } // namespace wsl::windows::wslc |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| VolumeInspectCommand.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of command execution logic. | ||
|
|
||
| --*/ | ||
|
|
||
| #include "VolumeCommand.h" | ||
| #include "CLIExecutionContext.h" | ||
| #include "SessionTasks.h" | ||
| #include "VolumeTasks.h" | ||
| #include "Task.h" | ||
|
|
||
| using namespace wsl::windows::wslc::execution; | ||
| using namespace wsl::windows::wslc::task; | ||
| using namespace wsl::shared; | ||
|
|
||
| namespace wsl::windows::wslc { | ||
| // Volume Inspect Command | ||
| std::vector<Argument> VolumeInspectCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::Create(ArgType::VolumeName, true, NO_LIMIT), | ||
| Argument::Create(ArgType::Session), | ||
| }; | ||
| } | ||
|
|
||
| std::wstring VolumeInspectCommand::ShortDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeInspectDesc(); | ||
| } | ||
|
|
||
| std::wstring VolumeInspectCommand::LongDescription() const | ||
| { | ||
| return Localization::WSLCCLI_VolumeInspectLongDesc(); | ||
| } | ||
|
|
||
| void VolumeInspectCommand::ExecuteInternal(CLIExecutionContext& context) const | ||
| { | ||
| context << CreateSession // | ||
| << InspectVolumes; | ||
| } | ||
| } // namespace wsl::windows::wslc |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.