# Flock Freight 人工录制（Windows）
#   npm run record:flock
#   npm run record:flock -- --logged-in
#   powershell -ExecutionPolicy Bypass -File scripts/record-flock.ps1 -LoggedIn

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

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