option('all'); $dryRun = !$this->option('force'); if (!$dryRun) { $this->warn("This operation is destructive and is not guaranteed to be fully accurate.\nEnsure you have a backup of your images.\n"); $proceed = $this->confirm("Are you sure you want to proceed?"); if (!$proceed) { return 0; } } $deleted = $imageService->deleteUnusedImages($checkRevisions, $dryRun); $deleteCount = count($deleted); if ($dryRun) { $this->comment('Dry run, no images have been deleted'); $this->comment($deleteCount . ' images found that would have been deleted'); $this->showDeletedImages($deleted); $this->comment('Run with -f or --force to perform deletions'); return 0; } $this->showDeletedImages($deleted); $this->comment($deleteCount . ' images deleted'); return 0; } protected function showDeletedImages($paths): void { if ($this->getOutput()->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) { return; } if (count($paths) > 0) { $this->line('Images to delete:'); } foreach ($paths as $path) { $this->line($path); } } }