# restart: stop then start
param(
    [switch]$Rebuild,
    [switch]$UseHost,
    [switch]$NoBrowser,
    [switch]$ShowConsole
)

$ErrorActionPreference = "Continue"
$Root = $PSScriptRoot
Set-Location -LiteralPath $Root

Write-Host "==> Restart: stopping..." -ForegroundColor Yellow
& (Join-Path $Root "scripts\Stop-Stack.ps1")
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne $null) {
    Write-Host "  (stop reported leftovers; continuing restart anyway)" -ForegroundColor DarkGray
}

Start-Sleep -Seconds 2

Write-Host "==> Restart: starting..." -ForegroundColor Cyan
& (Join-Path $Root "start.ps1") -Rebuild:$Rebuild -UseHost:$UseHost -NoBrowser:$NoBrowser -ShowConsole:$ShowConsole
exit $LASTEXITCODE
