# SPDX-FileCopyrightText: 2026 Mycel UG (haftungsbeschränkt) # SPDX-License-Identifier: MIT # # Install osf, the OmniScript command-line tool, on Windows (x64). # # irm https://osf.mycel.me/install.ps1 | iex # # Options (environment variables): # $env:OSF_VERSION = "2.0.0-alpha.6" install this version (default: latest) # $env:OSF_INSTALL_DIR = "C:\tools" install here (default: %LOCALAPPDATA%\Programs\osf\bin) # # The archive is downloaded from osf.mycel.me and checked against its # SHA-256 sum before anything is installed. Adds the folder to your user PATH. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $base = 'https://osf.mycel.me/download' $dir = if ($env:OSF_INSTALL_DIR) { $env:OSF_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\osf\bin' } if (-not [Environment]::Is64BitOperatingSystem) { throw 'osf needs 64-bit Windows' } $version = $env:OSF_VERSION if (-not $version) { $version = (Invoke-RestMethod "$base/latest").version } if ($version -notmatch '^[0-9A-Za-z.-]+$') { throw "bad version '$version'" } $file = 'osf-cli-x86_64-pc-windows-msvc.zip' $tmp = Join-Path ([IO.Path]::GetTempPath()) ("osf-install-" + [Guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host "osf-install: downloading osf $version for Windows x64" Invoke-WebRequest "$base/$version/$file" -OutFile (Join-Path $tmp $file) -UseBasicParsing $expected = ((Invoke-WebRequest "$base/$version/$file.sha256" -UseBasicParsing).Content -split '\s+')[0] $actual = (Get-FileHash (Join-Path $tmp $file) -Algorithm SHA256).Hash.ToLower() if ($expected.ToLower() -ne $actual) { throw "checksum mismatch for $file (expected $expected, got $actual)" } Expand-Archive (Join-Path $tmp $file) -DestinationPath $tmp -Force $exe = Get-ChildItem $tmp -Recurse -Filter 'osf.exe' | Select-Object -First 1 if (-not $exe) { throw 'osf.exe not found in the archive' } New-Item -ItemType Directory -Path $dir -Force | Out-Null Copy-Item $exe.FullName (Join-Path $dir 'osf.exe') -Force } finally { Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue } $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not (($userPath -split ';') -contains $dir)) { [Environment]::SetEnvironmentVariable('Path', ($(if ($userPath) { "$userPath;" } else { '' }) + $dir), 'User') $env:Path = "$env:Path;$dir" Write-Host "osf-install: added $dir to your user PATH (open a new terminal to use it)" } & (Join-Path $dir 'osf.exe') --version Write-Host "osf-install: installed to $dir\osf.exe"