Status: Open
Priority: High
Component: lib/wsl/commands.ps1, lib/wsl/commands.Tests.ps1
Parent: SC-016
Depends on: SC-016d
Summary: As a user, I want destructive operations (remove, terminate, shutdown) to ask for explicit confirmation so that I do not accidentally destroy data or stop running distributions.
Description:
Add a Confirm-DestructiveAction function wrapping Read-SpectreConfirm and wire it into the three destructive command functions. CLI paths (where -Name is provided) skip the confirmation to preserve scriptability.
- New
Confirm-DestructiveActionfunction incommands.ps1: takes-Actionstring (e.g., "Remove distribution 'Ubuntu'"), callsRead-SpectreConfirm, returns$true/$false Invoke-RemoveDistro: afterSelect-WslDistro, callConfirm-DestructiveActionbeforeRemove-WslDistro. Skip when-Namewas provided directly (non-interactive CLI)Invoke-TerminateDistro: after distro selection and running-state validation, confirm beforeStop-WslDistro. Skip when-Namewas providedInvoke-ShutdownWsl: confirm beforeStop-WslSubsystem, include running distro names in the confirmation message- Tests: mock
Read-SpectreConfirm, test confirmed proceeds, test denied aborts, test CLI paths skip confirmation
Acceptance Criteria:
-
Confirm-DestructiveActionfunction exists with Pester unit tests -
Invoke-RemoveDistroprompts for confirmation in interactive mode -
Invoke-TerminateDistroprompts for confirmation in interactive mode -
Invoke-ShutdownWslprompts for confirmation (shows running distro names) - Denying confirmation aborts the operation and returns to menu
- CLI mode (direct
-Nameparameter) skips confirmation - All existing tests continue to pass