win/brtwin.ps1

783 B · 35 lines · text

1# brtwin — Brew Remote Tools for Windows
2param(
3 [Parameter(ValueFromRemainingArguments = $true)]
4 [string[]]$BrtArgv
5)
6
7$ErrorActionPreference = "Stop"
8$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
9$Lib = Join-Path $Root "lib"
10$Py = Join-Path $Lib "brtwin.py"
11
12if (-not (Test-Path $Py)) {
13 Write-Error "brtwin.py not found at $Py"
14 exit 1
15}
16
17$pyCmd = Get-Command python -ErrorAction SilentlyContinue
18if (-not $pyCmd) {
19 $pyCmd = Get-Command py -ErrorAction SilentlyContinue
20}
21if (-not $pyCmd) {
22 Write-Error "Python 3 is required. Install from https://python.org"
23 exit 1
24}
25
26if ($null -eq $BrtArgv) { $BrtArgv = @() }
27
28$exe = $pyCmd.Source
29if ($exe -match "py\.exe$") {
30 & py -3 $Py @BrtArgv
31} else {
32 & $exe $Py @BrtArgv
33}
34exit $LASTEXITCODE
35