pm-convert/pm-convert

39 lines
834 B
PHP
Executable File

#!/usr/bin/env php
<?php
declare(strict_types=1);
use PmConverter\Handler;
const EOL = PHP_EOL;
const DS = DIRECTORY_SEPARATOR;
const PM_VERSION = '1.7';
$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.');
$handler = new Handler();
try {
$handler->init($argv);
$handler->start();
} catch (InvalidArgumentException $e) {
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
$handler::printHelp();
exit(1);
} catch (Exception $e) {
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), EOL));
exit(1);
}