setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv)); // 通过扫描目录 src/static-php-cli/command/ 添加子命令 $commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command'); $this->addCommands(array_map(function ($x) { return new $x(); }, array_filter($commands, function ($y) { if (is_a($y, DeployCommand::class, true) && (class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'))) { return false; } $reflection = new \ReflectionClass($y); return !$reflection->isAbstract() && !$reflection->isInterface(); }))); } /** * 重载以去除一些不必要的默认命令 */ protected function getDefaultCommands(): array { return [new HelpCommand(), new ListCommand()]; } }