Add "--force" option to index drop command

This commit is contained in:
Mathieu Darse
2014-09-16 16:10:17 +02:00
parent cd2cb3ad0e
commit 84d09f1b54

View File

@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Command\SearchEngine;
use Alchemy\Phrasea\Command\Command;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class IndexDropCommand extends Command
@@ -23,6 +24,12 @@ class IndexDropCommand extends Command
$this
->setName('searchengine:index:drop')
->setDescription('Deletes the search index')
->addOption(
'force',
null,
InputOption::VALUE_NONE,
"Don't ask for for the dropping of the index, but force the operation to run."
)
;
}
@@ -30,7 +37,11 @@ class IndexDropCommand extends Command
{
$question = '<question>You are about to delete the index and all contained data. Are you sure you wish to continue? (y/n)</question>';
if ($input->getOption('force')) {
$confirmation = true;
} else {
$confirmation = $this->getHelper('dialog')->askConfirmation($output, $question, false);
}
if ($confirmation) {
$indexer = $this->container['elasticsearch.indexer'];