input = $input; $this->io = new SymfonyStyle($input, $output); return $this->executeCommand(); } /** * Execute the actual command. */ abstract protected function executeCommand(): int; /** * Asks a confirmation question. */ public function confirm($question, $default = false): bool { return $this->io->confirm($question, ! $this->input->isInteractive()); } /** * @return array|InstalledPlugin[] */ protected function getAllPlugins(): array { return array_values( array_merge( $this->plugins->getAllPlugins() ?: [], $this->plugins->discoverNewPlugins(), ) ); } protected function getPlugin(string $name): InstalledPlugin { foreach ($this->getAllPlugins() as $plugin) { if ($name === $plugin->name) { return $plugin; } } throw new RuntimeException(sprintf('Invalid plugin name: %s', $name)); } }