| 1 | # Регистрация cide:// для dev (ADR 0157). Запуск от текущего пользователя (HKCU). |
| 2 | param( |
| 3 | [string]$ExePath = "", |
| 4 | [switch]$Unregister |
| 5 | ) |
| 6 | |
| 7 | $ErrorActionPreference = "Stop" |
| 8 | |
| 9 | if ([string]::IsNullOrWhiteSpace($ExePath)) { |
| 10 | $repoRoot = Split-Path -Parent $PSScriptRoot |
| 11 | $candidates = @( |
| 12 | (Join-Path $repoRoot "bin\Debug\net10.0\win-x64\CascadeIDE.exe"), |
| 13 | (Join-Path $repoRoot "bin\Debug\net10.0\CascadeIDE.exe"), |
| 14 | "D:\cascade-ide-debug\CascadeIDE.exe" |
| 15 | ) |
| 16 | foreach ($c in $candidates) { |
| 17 | if (Test-Path -LiteralPath $c) { |
| 18 | $ExePath = (Resolve-Path -LiteralPath $c).Path |
| 19 | break |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | if ([string]::IsNullOrWhiteSpace($ExePath) -or -not (Test-Path -LiteralPath $ExePath)) { |
| 25 | Write-Error "CascadeIDE.exe not found. Pass -ExePath or publish debug first." |
| 26 | } |
| 27 | |
| 28 | $scheme = "cide" |
| 29 | $baseKey = "Registry::HKEY_CURRENT_USER\Software\Classes\$scheme" |
| 30 | |
| 31 | if ($Unregister) { |
| 32 | if (Test-Path -LiteralPath $baseKey) { |
| 33 | Remove-Item -LiteralPath $baseKey -Recurse -Force |
| 34 | Write-Host "Removed $scheme:// protocol registration." |
| 35 | } |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | New-Item -Path $baseKey -Force | Out-Null |
| 40 | Set-ItemProperty -Path $baseKey -Name "(Default)" -Value "URL:Cascade IDE Magic Link" |
| 41 | Set-ItemProperty -Path $baseKey -Name "URL Protocol" -Value "" |
| 42 | |
| 43 | $iconKey = Join-Path $baseKey "DefaultIcon" |
| 44 | New-Item -Path $iconKey -Force | Out-Null |
| 45 | Set-ItemProperty -Path $iconKey -Name "(Default)" -Value "$ExePath,0" |
| 46 | |
| 47 | $commandKey = Join-Path $baseKey "shell\open\command" |
| 48 | New-Item -Path $commandKey -Force | Out-Null |
| 49 | $command = "`"$ExePath`" `"%1`"" |
| 50 | Set-ItemProperty -Path $commandKey -Name "(Default)" -Value $command |
| 51 | |
| 52 | Write-Host "Registered $scheme:// -> $ExePath" |
| 53 | Write-Host "Example: ${scheme}://reveal?root=$( [uri]::EscapeDataString($repoRoot) )&f=Program.cs&l=1" |
| 54 | |