/**
* Internal function to execute the command.
*
* @param InputInterface $input The input to inject into the command.
* @param OutputInterface $output The output to inject into the command.
*
* @return integer The command exit code
*
* @since 4.0.0
*/
protected function doExecute(InputInterface $input, OutputInterface $output) : int
{
// Initialize the time value.
$this->time = microtime(true);
$this->configureIO($input, $output);
$this->ioStyle->writeln(['<info>Finder Indexer</>', '<info>==========================</>', '']);
if ($this->cliInput->getOption('minproctime')) {
$this->minimumBatchProcessingTime = $this->cliInput->getOption('minproctime');
}
if ($this->cliInput->getOption('pause')) {
$this->pause = $this->cliInput->getOption('pause');
}
if ($this->cliInput->getOption('divisor')) {
$this->divisor = $this->cliInput->getOption('divisor');
}
if ($this->cliInput->getArgument('purge')) {
// Taxonomy ids will change following a purge/index, so save filter information first.
$this->getFilters();
// Purge the index.
$this->purge();
// Run the indexer.
$this->index();
// Restore the filters again.
$this->putFilters();
} else {
$this->index();
}
$this->ioStyle->newLine(1);
// Total reporting.
$this->ioStyle->writeln(['<info>' . Text::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->time, 3)) . '</>', '<info>' . Text::sprintf('FINDER_CLI_PEAK_MEMORY_USAGE', number_format(memory_get_peak_usage(true))) . '</>']);
$this->ioStyle->newLine(1);
return Command::SUCCESS;
}