setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv)); // Add subcommands by scanning the directory src/static-php-cli/command/ $commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command'); $phar = class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'); $commands = array_filter($commands, function ($y) use ($phar) { $archive_blacklist = [ 'SPC\command\dev\SortConfigCommand', 'SPC\command\DeployCommand', ]; if ($phar && in_array($y, $archive_blacklist)) { return false; } $reflection = new \ReflectionClass($y); return !$reflection->isAbstract() && !$reflection->isInterface(); }); $this->addCommands(array_map(function ($x) { return new $x(); }, $commands)); } protected function getDefaultCommands(): array { return [new HelpCommand(), new ListCommand()]; } }