Octa.psm1

#Requires -Version 5.1

# FR-009: refuse to run on anything but Windows 11, naming the detected OS.
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
$buildNumber = [int]$osInfo.BuildNumber
if ($buildNumber -lt 22000) {
    throw "Octa requires Windows 11 (build 22000 or later). Detected: $($osInfo.Caption) (build $buildNumber)."
}

# HKCR: isn't a default PowerShell registry drive (only HKLM:/HKCU: are) - some 006 actions
# target HKEY_CLASSES_ROOT context-menu handler keys, so create it once here rather than in
# every category file that needs it.
if (-not (Get-PSDrive -Name HKCR -ErrorAction SilentlyContinue)) {
    New-PSDrive -PSProvider Registry -Name HKCR -Root HKEY_CLASSES_ROOT -Scope Global | Out-Null
}

$root = $PSScriptRoot

foreach ($folder in 'private', 'categories', 'public') {
    $path = Join-Path $root $folder
    if (Test-Path $path) {
        Get-ChildItem -Path $path -Filter '*.ps1' | ForEach-Object {
            . $_.FullName
        }
    }
}