xcat 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env php
  2. <?php
  3. declare(strict_types=1);
  4. use App\Services\Boot;
  5. require __DIR__ . '/app/predefine.php';
  6. require __DIR__ . '/vendor/autoload.php';
  7. require __DIR__ . '/config/.config.php';
  8. Boot::setTime();
  9. Boot::bootSentry();
  10. Boot::bootDb();
  11. if (!isset($argv[1])) {
  12. $commandPath = BASE_PATH . '/src/Command/';
  13. $allCommandFiles = glob($commandPath . '*.php');
  14. $allCommands = str_replace(
  15. [
  16. $commandPath,
  17. '.php'
  18. ],
  19. [
  20. '\\App\\Command\\',
  21. ''
  22. ],
  23. $allCommandFiles
  24. );
  25. echo PHP_EOL;
  26. foreach ($allCommands as $commandClass) {
  27. if ($commandClass == '\\App\\Command\\Command') {
  28. continue;
  29. }
  30. if (!class_exists($commandClass)) {
  31. continue;
  32. }
  33. $triggerObject = new $commandClass($argv);
  34. if (!property_exists($triggerObject, 'description')) {
  35. continue;
  36. }
  37. echo trim($triggerObject->description) . PHP_EOL;
  38. }
  39. return;
  40. }
  41. $classPath = '\\App\\Command\\' . $argv[1];
  42. if (class_exists($classPath)) {
  43. $trigger = new $classPath($argv);
  44. $trigger->boot();
  45. } else {
  46. echo 'Unable to load class: ' . $classPath . PHP_EOL;
  47. }