Files
NexusOS/management/ncp.ps1
T
2026-07-22 11:41:03 -05:00

42 lines
1.7 KiB
PowerShell

# ncp - PowerShell entry point. The CLI itself is management/ncp.py, the same
# file the Linux shell wrapper runs; this only picks an interpreter and forwards
# the arguments.
#
# Windows: install-windows.ps1 registers this automatically. To do it by hand,
# or to get ncp inside PowerShell on Linux, add to $PROFILE.CurrentUserAllHosts:
#
# function ncp { & "<repo>/management/ncp.ps1" @args }
#
# ASCII only, no exceptions: PowerShell 5.1 decodes BOM-less files as ANSI, so a
# single Unicode dash eats a quote and the script dies at parse time. A test in
# tests/test_smoke.py fails if any .ps1 in this repo gains a non-ASCII byte.
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
# Forward slashes and per-platform venv layout: backslash is a literal character
# on Linux, not a separator, so "Promethean\Scripts\python.exe" would resolve to
# a single nonsense filename under pwsh on Linux. Windows accepts "/" happily.
# $env:OS is the 5.1-safe check; the automatic $IsWindows only exists on PS 6+.
$OnWindows = ($env:OS -eq "Windows_NT")
if ($OnWindows) {
$Py = Join-Path $Root "Promethean/Scripts/python.exe"
} else {
$Py = Join-Path $Root "Promethean/bin/python3"
}
# Fall back to a system Python so backup/restore still work before the venv is
# built - those delegate to the stdlib-only bin/sync.py.
if (-not (Test-Path $Py)) {
foreach ($candidate in @("python3", "python")) {
$found = Get-Command $candidate -ErrorAction SilentlyContinue
if ($found) { $Py = $found.Source; break }
}
}
if (-not (Test-Path $Py)) {
Write-Error "No Python found. Run install.sh (Linux) or install-windows.ps1 first."
exit 1
}
& $Py (Join-Path $Root "management/ncp.py") @args
exit $LASTEXITCODE