xeq 1.6.2

Run sequences of commands from a TOML file with a single word
$ErrorActionPreference = "Stop"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Write-Host "Installing xeq for Windows..." -ForegroundColor Green

try {
    $webClient = New-Object System.Net.WebClient
    $webClient.Headers.Add("User-Agent", "PowerShell")

    $apiResponse = $webClient.DownloadString("https://api.github.com/repos/opmr0/xeq/releases/latest")
    $version = ($apiResponse | ConvertFrom-Json).tag_name

    if (-not $version) { throw "Failed to fetch latest release version" }

    $downloadUrl = "https://github.com/opmr0/xeq/releases/download/$version/xeq-windows-x86_64.exe"
    $tempFile = Join-Path $env:TEMP "xeq.exe"

    Write-Host "Downloading $version..." -ForegroundColor Cyan
    $webClient.DownloadFile($downloadUrl, $tempFile)

    $installDir = Join-Path $env:LOCALAPPDATA "Programs\xeq"
    if (-not (Test-Path $installDir)) {
        New-Item -ItemType Directory -Path $installDir -Force | Out-Null
    }

    $finalPath = Join-Path $installDir "xeq.exe"
    if (Test-Path $finalPath) { Remove-Item $finalPath -Force }
    Move-Item $tempFile $finalPath -Force

    $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
    if ($userPath -notlike "*$installDir*") {
        [Environment]::SetEnvironmentVariable("Path", $userPath + ";" + $installDir, "User")
        $env:Path = [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + $userPath + ";" + $installDir
        Write-Host "Added to PATH" -ForegroundColor Green
        Write-Host "Restart your terminal for PATH changes to take effect" -ForegroundColor Yellow
    }

    Write-Host ""
    Write-Host "xeq installed successfully!" -ForegroundColor Green
    Write-Host "Run 'xeq --help' to get started" -ForegroundColor Cyan

} catch {
    Write-Host "Installation failed: $_" -ForegroundColor Red
    Write-Host ""
    Write-Host "Manual installation:" -ForegroundColor Yellow
    Write-Host "1. Go to: https://github.com/opmr0/xeq/releases/latest" -ForegroundColor Yellow
    Write-Host "2. Download: xeq-windows-x86_64.exe" -ForegroundColor Yellow
    Write-Host "3. Rename to xeq.exe and move to a folder in your PATH" -ForegroundColor Yellow
    exit 1
}