param(
    [string]$Test   = "",
    [string]$Filter = ""
)

Write-Host ""
Write-Host "=== Entropyk Dev Environment ===" -ForegroundColor Cyan

$env:PATH += ";$env:USERPROFILE\.cargo\bin"
$env:PATH += ";C:\Program Files\CMake\bin"

$msvcBase = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207"
$env:PATH += ";$msvcBase\bin\Hostx64\x64"

$sdkVersion = "10.0.26100.0"
$sdkBase = "C:\Program Files (x86)\Windows Kits\10"
$env:LIB     = "$msvcBase\lib\x64;$sdkBase\lib\$sdkVersion\um\x64;$sdkBase\lib\$sdkVersion\ucrt\x64"
$env:INCLUDE = "$msvcBase\include;$sdkBase\Include\$sdkVersion\ucrt;$sdkBase\Include\$sdkVersion\um"
$env:PATH   += ";$sdkBase\bin\$sdkVersion\x64"

Set-Location "C:\Users\serameza\impact\dev\Entropyk-main\entropyk"

$cargoOk = Get-Command cargo -ErrorAction SilentlyContinue
if ($cargoOk) {
    $ver = cargo --version 2>&1
    Write-Host "OK Cargo : $ver" -ForegroundColor Green
} else {
    Write-Host "ERREUR: Cargo introuvable" -ForegroundColor Red
    return
}

$linkOk = Get-Command link.exe -ErrorAction SilentlyContinue
if ($linkOk) {
    Write-Host "OK Linker: link.exe trouve" -ForegroundColor Green
} else {
    Write-Host "ERREUR: link.exe introuvable" -ForegroundColor Red
}

Write-Host ""
Write-Host "Repertoire: $(Get-Location)" -ForegroundColor Yellow
Write-Host ""
Write-Host "--- Commandes ---" -ForegroundColor Cyan
Write-Host "  cargo test --package entropyk-core"
Write-Host "  cargo test --package entropyk-fluids"
Write-Host "  cargo test --package entropyk-components"
Write-Host "  cargo test --package entropyk-solver"
Write-Host "  cargo test --package entropyk-vendors"
Write-Host "  cargo test --package entropyk-cli"
Write-Host "  cargo test --package entropyk-fluids -- --nocapture"
Write-Host ""
Write-Host "--- Via ce script ---" -ForegroundColor Cyan
Write-Host "  . .\dev-env.ps1 -Test entropyk-fluids"
Write-Host "  . .\dev-env.ps1 -Test entropyk-fluids -Filter test_water_density"
Write-Host ""

if ($Test -ne "") {
    if ($Filter -ne "") {
        Write-Host ">> cargo test --package $Test $Filter -- --nocapture" -ForegroundColor Magenta
        cargo test --package $Test $Filter -- --nocapture
    } else {
        Write-Host ">> cargo test --package $Test -- --nocapture" -ForegroundColor Magenta
        cargo test --package $Test -- --nocapture
    }
}