83 lines
2.4 KiB
PHP
Executable File
83 lines
2.4 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php declare(strict_types=1);
|
|
|
|
/*
|
|
* Copyright (c) 2018 https://sikofitt.com sikofitt@sikofitt.com
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
use Symfony\Component\Console\{
|
|
Application,
|
|
Command\Command
|
|
};
|
|
|
|
use Sikofitt\GenerateMac\Command\GenerateMacCommand;
|
|
|
|
define('GENERATE_MAC_VERSION', 'v0.0.1');
|
|
|
|
$autoloadFiles = array(
|
|
__DIR__ . '/../vendor/autoload.php',
|
|
__DIR__ . '/../../../autoload.php',
|
|
);
|
|
|
|
foreach ($autoloadFiles as $autoloadFile) {
|
|
if (file_exists($autoloadFile)) {
|
|
require $autoloadFile;
|
|
define('GENERATE_MAC', $autoloadFile);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!defined('GENERATE_MAC')) {
|
|
|
|
$msg =
|
|
PHP_EOL . 'You need to use composer to install the dependencies:' . PHP_EOL .
|
|
'curl -LSs https://getcomposer.org/installer|php' . PHP_EOL .
|
|
'php composer.phar install, or ' . PHP_EOL .
|
|
'php composer.phar install --no-dev && php composer.phar require symfony/console' . PHP_EOL . PHP_EOL
|
|
;
|
|
|
|
print $msg;
|
|
|
|
throw new \RuntimeException('Missing dependencies', -1);
|
|
}
|
|
|
|
if(false === class_exists(Command::class))
|
|
{
|
|
$msg =
|
|
PHP_EOL . 'You need to use composer to install the dependencies for the console:' . PHP_EOL .
|
|
'php composer.phar require symfony/console' . PHP_EOL . PHP_EOL
|
|
;
|
|
print $msg;
|
|
|
|
throw new \RuntimeException('Missing package symfony/console.', -1);
|
|
}
|
|
|
|
$application = new Application('Generate mac', GENERATE_MAC_VERSION);
|
|
|
|
$application
|
|
->add(new GenerateMacCommand());
|
|
|
|
$application
|
|
->setDefaultCommand('generate-mac', true)
|
|
->setAutoExit(true);
|
|
|
|
try {
|
|
$application->run();
|
|
} catch (Exception $e) {
|
|
printf('Couldn\'t run the application.%s', PHP_EOL);
|
|
printf('Error was: %s at %s:%s%s', $e->getMessage(), $e->getFile(), $e->getLine(), PHP_EOL);
|
|
}
|