#!/usr/bin/env php
<?php

declare(strict_types=1);

use GuzzleHttp\Client;
use MadeByDenis\WpPestIntegrationTestSetup\Command\InitCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;

if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
    echo 'Warning: The console should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL;
}

// Used when running the wp-pest command from composer.
$vendorPath = dirname(__DIR__, 4) . '/vendor/autoload.php';

// Used for local development.
$localPath = dirname(__DIR__) . '/vendor/autoload.php';

if (file_exists($vendorPath)) {
    require_once $vendorPath;
    $autoloadPath = $vendorPath;
} else {
    require_once $localPath;
    $autoloadPath = $localPath;
}

$rootPath = dirname($autoloadPath, 2);

$app = new Application();

$app->add(new InitCommand($rootPath, new Filesystem(), new Client()));

$app->run();
