mirror of
https://github.com/Dannecron/coverage-merger.git
synced 2025-12-25 15:52:34 +03:00
75 lines
1.8 KiB
PHP
Executable File
75 lines
1.8 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Dannecron\CoverageMerger\Command\Exceptions\CommandException;
|
|
use Dannecron\CoverageMerger\Command\CloverMergeCommand;
|
|
use Dannecron\CoverageMerger\Clover;
|
|
|
|
if (isset($GLOBALS['_composer_autoload_path'])) {
|
|
require_once $GLOBALS['_composer_autoload_path'];
|
|
} else {
|
|
$knownAutoloadPaths = [
|
|
__DIR__ . '/../../autoload.php',
|
|
__DIR__ . '/../vendor/autoload.php',
|
|
__DIR__ . '/vendor/autoload.php',
|
|
];
|
|
|
|
foreach ($knownAutoloadPaths as $path) {
|
|
if (\file_exists($path)) {
|
|
require_once $path;
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
unset($knownAutoloadPaths, $path);
|
|
}
|
|
|
|
$appVersion = \getenv('MERGER_VERSION');
|
|
if ($appVersion === false) {
|
|
$appVersion = 'dev';
|
|
}
|
|
|
|
$app = new \Ahc\Cli\Application('clover-merger', $appVersion);
|
|
|
|
$app->onException(static function (\Throwable $exception, int $exitCode) use ($app): void {
|
|
$io = $app->io();
|
|
|
|
$io->error($exception->getMessage(), true);
|
|
|
|
if (($exception instanceof CommandException) === false) {
|
|
exit($exitCode);
|
|
}
|
|
|
|
if ($exception->isVerbose() === false) {
|
|
exit($exception->getCode());
|
|
}
|
|
|
|
$trace = $exception->getTrace();
|
|
$io->table(\array_map(static function (array $traceStep): array {
|
|
$methodOrFunc = \array_key_exists('class', $traceStep)
|
|
? "{$traceStep['class']}::{$traceStep['function']}"
|
|
: $traceStep['function'];
|
|
|
|
return [
|
|
'method/func' => $methodOrFunc,
|
|
'file' => "{$traceStep['file']}:{$traceStep['line']}",
|
|
|
|
];
|
|
}, $trace));
|
|
|
|
exit($exception->getCode());
|
|
});
|
|
|
|
$app->add(
|
|
new CloverMergeCommand(
|
|
new Clover\Handler(new Clover\Parser()),
|
|
new Clover\Renderer(),
|
|
$app,
|
|
),
|
|
);
|
|
|
|
$app->handle($_SERVER['argv']);
|