pm-convert/pm-convert

36 lines
810 B
PHP
Executable File

#!/usr/bin/env php
<?php
declare(strict_types=1);
const EOL = PHP_EOL;
const DS = DIRECTORY_SEPARATOR;
use PmConverter\Processor;
$paths = [
__DIR__ . '/../../autoload.php',
__DIR__ . '/../autoload.php',
__DIR__ . '/vendor/autoload.php'
];
$file = null;
foreach ($paths as $path) {
if (file_exists($path)) {
require_once $file = $path;
break;
}
}
is_null($file) && throw new RuntimeException('Unable to locate autoload.php file.');
$processor = new Processor($argv);
try {
$processor->handle();
} catch (InvalidArgumentException $e) {
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
print(implode(EOL, Processor::usage()));
die(1);
} catch (Exception $e) {
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
die(1);
}