CLI: Initialize volume prune functionality#40307
CLI: Initialize volume prune functionality#40307AmelBawa-msft wants to merge 2 commits intofeature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds initial CLI support for wslc volume prune, including command wiring, service/task plumbing, localization strings, and end-to-end test coverage for core prune scenarios.
Changes:
- Register new
volume prunesubcommand and wire it through command → task → service layers. - Add localization strings for prune help/output and include prune in volume help listing.
- Add new E2E tests covering prune help,
--all, multiple volumes, in-use volume behavior, and idempotency.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/wslc/e2e/WSLCE2EVolumeTests.cpp | Adds prune to the list of expected volume subcommands in help. |
| test/windows/wslc/e2e/WSLCE2EVolumePruneTests.cpp | New E2E test suite for wslc volume prune. |
| src/windows/wslc/tasks/VolumeTasks.h | Declares new PruneVolumes task entry point. |
| src/windows/wslc/tasks/VolumeTasks.cpp | Implements prune task and prints deleted volumes + reclaimed space. |
| src/windows/wslc/services/VolumeService.h | Adds VolumeService::Prune API. |
| src/windows/wslc/services/VolumeService.cpp | Implements service call into session PruneVolumes. |
| src/windows/wslc/services/VolumeModel.h | Adds PruneVolumesResult model for deleted volumes + reclaimed space. |
| src/windows/wslc/commands/VolumePruneCommand.cpp | New command implementation for volume prune. |
| src/windows/wslc/commands/VolumeCommand.h | Declares VolumePruneCommand. |
| src/windows/wslc/commands/VolumeCommand.cpp | Registers VolumePruneCommand under volume. |
| localization/strings/en-US/Resources.resw | Adds user-facing strings for prune descriptions, output, and args. |
| WSLC_TEST_METHOD(WSLCE2E_Volume_Prune_AllFlag) | ||
| { | ||
| // Create a named volume, then prune with --all | ||
| RunWslc(std::format(L"volume create --name {}", TestVolumeName1)).Verify({.Stderr = L"", .ExitCode = 0}); | ||
| VerifyVolumeIsListed(TestVolumeName1); | ||
|
|
||
| const auto result = RunWslc(L"volume prune --all"); | ||
| result.Verify({.Stderr = L"", .ExitCode = 0}); | ||
|
|
||
| VerifyStdoutContains(result, L"Deleted:"); | ||
| VerifyStdoutContains(result, L"Total reclaimed space:"); | ||
|
|
||
| // Verify the volume was actually removed | ||
| VerifyVolumeIsNotListed(TestVolumeName1); | ||
| } |
There was a problem hiding this comment.
The E2E suite covers volume prune --all but does not cover the default behavior of volume prune without --all (i.e., that named volumes should not be removed when --all is omitted). Adding a test that creates a named volume, runs volume prune (no flags), and verifies the volume remains would exercise the non---all path and prevent regressions in default semantics.
| PrintMessage(Localization::WSLCCLI_VolumePruneDeleted(volume)); | ||
| } | ||
|
|
||
| PrintMessage(L""); |
There was a problem hiding this comment.
A blank line is always printed even when no volumes are deleted. This creates avoidable output churn and makes CLI output harder to parse consistently. Consider only printing the separator line when result.DeletedVolumes is non-empty (or otherwise aligning output formatting with the rest of the CLI’s conventions for empty results).
| PrintMessage(L""); | |
| if (!result.DeletedVolumes.empty()) | |
| { | |
| PrintMessage(L""); | |
| } |
| std::vector<Argument> VolumePruneCommand::GetArguments() const | ||
| { | ||
| return { | ||
| Argument::Create(ArgType::All, std::nullopt, std::nullopt, Localization::WSLCCLI_VolumePruneAllArgDescription()), |
There was a problem hiding this comment.
The help text in the new E2E test expects -a,--all, but the argument registration passes std::nullopt for both names. If ArgType::All does not implicitly define -a/--all in this codebase, the command will not expose the intended flags and help output will diverge. To make the CLI contract explicit, define the short/long forms directly here (or adjust the help expectations to match the actual registered flags).
| Argument::Create(ArgType::All, std::nullopt, std::nullopt, Localization::WSLCCLI_VolumePruneAllArgDescription()), | |
| Argument::Create(ArgType::All, L"a", L"all", Localization::WSLCCLI_VolumePruneAllArgDescription()), |
|
WSLCSession::PruneVolumes returns E_NOTIMPL. The CLI is wired up but the backend is a stub, so this will always throw. Hold this until the actual prune logic exists. |
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed