Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.94 KB

File metadata and controls

34 lines (26 loc) · 1.94 KB

<- Back to Backlog

[SC-016e] Add Read-SpectreConfirm for destructive operations

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.

Technical approach

  • New Confirm-DestructiveAction function in commands.ps1: takes -Action string (e.g., "Remove distribution 'Ubuntu'"), calls Read-SpectreConfirm, returns $true/$false
  • Invoke-RemoveDistro: after Select-WslDistro, call Confirm-DestructiveAction before Remove-WslDistro. Skip when -Name was provided directly (non-interactive CLI)
  • Invoke-TerminateDistro: after distro selection and running-state validation, confirm before Stop-WslDistro. Skip when -Name was provided
  • Invoke-ShutdownWsl: confirm before Stop-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-DestructiveAction function exists with Pester unit tests
  • Invoke-RemoveDistro prompts for confirmation in interactive mode
  • Invoke-TerminateDistro prompts for confirmation in interactive mode
  • Invoke-ShutdownWsl prompts for confirmation (shows running distro names)
  • Denying confirmation aborts the operation and returns to menu
  • CLI mode (direct -Name parameter) skips confirmation
  • All existing tests continue to pass

<- Back to Backlog