| 1 | # brtwin — Brew Remote Tools for Windows |
| 2 | param( |
| 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 | |
| 12 | if (-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 |
| 18 | if (-not $pyCmd) { |
| 19 | $pyCmd = Get-Command py -ErrorAction SilentlyContinue |
| 20 | } |
| 21 | if (-not $pyCmd) { |
| 22 | Write-Error "Python 3 is required. Install from https://python.org" |
| 23 | exit 1 |
| 24 | } |
| 25 | |
| 26 | if ($null -eq $BrtArgv) { $BrtArgv = @() } |
| 27 | |
| 28 | $exe = $pyCmd.Source |
| 29 | if ($exe -match "py\.exe$") { |
| 30 | & py -3 $Py @BrtArgv |
| 31 | } else { |
| 32 | & $exe $Py @BrtArgv |
| 33 | } |
| 34 | exit $LASTEXITCODE |
| 35 | |