#!/bin/nu

def --wrapped main [...rest] {
    cd $env.WEBROOT

    mut args = $rest;
    mut command = "phpunit";
    if (($args | first | detect type | describe) == "int") {
        let phpunit_version = $rest | first
        $command = $"phpunit($phpunit_version)"
        $args = $args | skip 1
    }

    let command = $command
    let args = $args
    XDEBUG_SESSION=haze exec $command --configuration $"($env.WEBROOT)/tests/phpunit-autotest.xml" ...$args
}
