-
Notifications
You must be signed in to change notification settings - Fork 15
/
reli
executable file
·56 lines (46 loc) · 1.5 KB
/
reli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env php
<?php
/**
* This file is part of the reliforp/reli-prof package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use DI\ContainerBuilder;
use Reli\Command\CommandEnumerator;
use Reli\Lib\Log\Log;
use Reli\ReliProfiler;
use Psr\Log\LoggerInterface;
use Reli\Lib\Log\StateCollector\StateCollector;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
$not_loaded = true;
foreach ([__DIR__ . '/vendor/autoload.php', __DIR__ . '/../../autoload.php'] as $autoload) {
if (file_exists($autoload)) {
require $autoload;
}
$not_loaded = false;
}
if ($not_loaded) {
echo 'Autoloader was not loaded.', PHP_EOL;
exit(1);
}
$application = new Application();
$container = (new ContainerBuilder())->addDefinitions(__DIR__ . '/config/di.php')->build();
$application->setName(ReliProfiler::TOOL_NAME);
$application->setVersion(ReliProfiler::getVersion());
Log::initializeLogger(
$container->make(LoggerInterface::class),
$container->make(StateCollector::class),
);
/** @var iterable<class-string> $command_enumerator */
$command_enumerator = new CommandEnumerator(new GlobIterator(__DIR__. '/src/Command/*/*Command.php'));
foreach ($command_enumerator as $command_class) {
/** @var Command $command */
$command = $container->make($command_class);
$application->add($command);
}
$application->run();