setName('mautic:unusedip:delete') ->addOption( '--limit', '-l', InputOption::VALUE_OPTIONAL, 'LIMIT for deleted rows', self::DEFAULT_LIMIT ) ->setHelp( <<<'EOT' The %command.name% command is used to delete IP addresses that are not used in any other database table. php %command.full_name% EOT ); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output): int { if (!$this->checkRunStatus($input, $output)) { return \Symfony\Component\Console\Command\Command::SUCCESS; } try { $limit = $input->getOption('limit') ?? self::DEFAULT_LIMIT; $deletedRows = $this->ipAddressModel->deleteUnusedIpAddresses((int) $limit); $output->writeln(sprintf('%s unused IP addresses have been deleted', $deletedRows)); } catch (\Doctrine\DBAL\Exception $e) { $output->writeln(sprintf('Deletion of unused IP addresses failed because of database error: %s', $e->getMessage())); $this->completeRun(); return \Symfony\Component\Console\Command\Command::FAILURE; } $this->completeRun(); return \Symfony\Component\Console\Command\Command::SUCCESS; } protected static $defaultDescription = 'Deletes IP addresses that are not used in any other database table'; }