setName("pdo:shell"); $this->setDescription("Launch an interactive PDO shell"); $this->addOption("db", null, InputOption::VALUE_REQUIRED, "Select database resource", "db"); $this->addOption("read", "r", InputOption::VALUE_REQUIRED, "Read commands to execute from file"); } protected function execute(InputInterface $input, OutputInterface $output) { $shell = new Shell\PdoShell($output); $db = $input->getOption("db"); $read = $input->getOption("read"); if ($read) { if (!file_exists($read)) { $output->writeln("File not found: {$read}"); return Command::FAILURE; } $file = file($read, FILE_IGNORE_NEW_LINES); $shell->runCommands($file); } else { $shell->runCommands([ ".select {$db}" ]); $shell->run(); } return Command::SUCCESS; } }