protected function execute(InputInterface $input, OutputInterface $output) { if (Pad::deletePad($input->getArgument('padId'), $input->getOption('apikey'), $input->getOption('host'))) { $output->writeln('Pad sucessfully deleted!'); } else { $output->writeln('Pad could not deleted!'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $this->setThreshold($input->getOption('days')); if ($input->getOption('dry-run')) { $output->writeln('<info>This is a dry-run run, no pad will deleted.</info>'); } if ($output->isVerbose()) { $output->writeln(sprintf('<info>INFO:</info> Pads before %s will be deleted', $this->threshold->format($this->dateFormat))); } $padIds = $this->getAllPads($input->getOption('apikey'), $input->getOption('host')); if ($padIds === false) { $output->writeln('<error>Could not receive all pads.</error>'); return; } if ($output->isVerbose()) { $output->writeln(sprintf('<info>INFO:</info> %s pad(s) stored', $this->countPads)); } foreach ($padIds as $padId) { $lastEdited = Pad::getLastEdited($padId, $input->getOption('apikey'), $input->getOption('host')); if ($lastEdited === false) { $this->countPadsFailed++; continue; } if ($lastEdited < $this->threshold->getTimestamp()) { if ($output->isDebug()) { $output->writeln(sprintf('<info>DEBUG:</info> "%s" was last edited on %s and will purged', $padId, date($this->dateFormat, $lastEdited))); } if (!$input->getOption('dry-run')) { if (!Pad::deletePad($padId, $input->getOption('apikey'), $input->getOption('host'))) { $this->countPadsFailed++; } } $this->countPadsDeleted++; } } if ($output->isVerbose()) { $output->writeln(sprintf('<info>INFO:</info> %s pad(s) deleted', $this->countPadsDeleted)); $output->writeln(sprintf('<info>INFO:</info> %s pad(s) failed', $this->countPadsFailed)); } }