/** * Remove all Documents from the given database * * @param string $database Name of the database to remove */ public function removeDatabaseCommand($database) { $this->documentRepository->setDatabase($database); $count = $this->documentRepository->countAll(); if ($count == 0) { $this->outputLine('Database "' . $database . '" is empty'); return; } // Ask before deleting $prompt = 'Remove ' . $count . ' documents from database "' . $database . '" [yn]?'; if (function_exists('readline')) { $choice = readline($prompt); } else { echo $prompt . ' '; $choice = stream_get_line(STDIN, 1024, PHP_EOL); } if ($choice === 'y') { $this->outputLine(static::ESCAPE . static::RED . 'Deleting ' . $count . ' documents' . static::ESCAPE . static::NORMAL); $this->documentRepository->removeAllFromDatabase($database); } else { $this->outputLine('Nothing deleted'); } }