[CmdletBinding()]
param(
  [switch]$Plan,
  [switch]$Force
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$installScript = Join-Path $PSScriptRoot 'tools/install/install-agent.ps1'
if (-not (Test-Path -LiteralPath $installScript -PathType Leaf)) {
  throw "找不到 tools/install/install-agent.ps1: $installScript"
}

$forwardArgs = @{
  Scope = 'user'
}

if ($Plan.IsPresent) {
  $forwardArgs['Plan'] = $true
}

if ($Force.IsPresent) {
  $forwardArgs['Force'] = $true
}

Write-Output 'AliasScope: user'
& $installScript @forwardArgs
exit $LASTEXITCODE
