-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
xcat
53 lines (47 loc) · 1.21 KB
/
xcat
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
#!/usr/bin/env php
<?php
declare(strict_types=1);
use App\Services\Boot;
require __DIR__ . '/app/predefine.php';
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/config/.config.php';
Boot::setTime();
Boot::bootSentry();
Boot::bootDb();
if (!isset($argv[1])) {
$commandPath = BASE_PATH . '/src/Command/';
$allCommandFiles = glob($commandPath . '*.php');
$allCommands = str_replace(
[
$commandPath,
'.php'
],
[
'\\App\\Command\\',
''
],
$allCommandFiles
);
echo PHP_EOL;
foreach ($allCommands as $commandClass) {
if ($commandClass == '\\App\\Command\\Command') {
continue;
}
if (!class_exists($commandClass)) {
continue;
}
$triggerObject = new $commandClass($argv);
if (!property_exists($triggerObject, 'description')) {
continue;
}
echo trim($triggerObject->description) . PHP_EOL;
}
return;
}
$classPath = '\\App\\Command\\' . $argv[1];
if (class_exists($classPath)) {
$trigger = new $classPath($argv);
$trigger->boot();
} else {
echo 'Unable to load class: ' . $classPath . PHP_EOL;
}