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

declare(strict_types=1);

use Aeliot\PHPUnitCodeCoverageBaseline\Command\CloverBuildBaselineCommand;
use Aeliot\PHPUnitCodeCoverageBaseline\Command\CloverCompareCommand;
use Aeliot\PHPUnitCodeCoverageBaseline\Enum\Version;
use Symfony\Component\Console\Application;

require __DIR__ . '/include_autoloader.php';

try {
    $application = new Application('PCCB', Version::CURRENT);
    $application->add(new CloverCompareCommand());
    $application->add(new CloverBuildBaselineCommand());
    $exitCode = $application->run();
} catch (\Throwable $exception) {
    fwrite(STDERR, sprintf('[ERROR] %s%s', $exception->getMessage(), PHP_EOL));
    $exitCode = 2;
}

if ($exitCode) {
    exit($exitCode);
}
