# Windows 录制入口（无需 bash/WSL）
# Usage:
#   npm run record:mothership
#   npm run record:mothership -- --logged-in
#   powershell -ExecutionPolicy Bypass -File scripts/record-mothership.ps1 -LoggedIn
#   powershell -ExecutionPolicy Bypass -File scripts/record-mothership.ps1 -StartUrl "https://..." -LoggedIn

param(
    [string]$StartUrl,
    [switch]$LoggedIn
)

$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $PSScriptRoot
Push-Location $Root
try {
    if ($LoggedIn -and $StartUrl) {
        npm run record:mothership -- --logged-in $StartUrl
    }
    elseif ($LoggedIn) {
        npm run record:mothership -- --logged-in
    }
    elseif ($StartUrl) {
        npm run record:mothership -- $StartUrl
    }
    else {
        npm run record:mothership
    }
    if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
finally {
    Pop-Location
}
