diff --git a/composer.json b/composer.json index 67727ed..076e380 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "php": "^8.1", "illuminate/contracts": "^10.0|^11.0", "laravel/helpers": "^1.7", + "spatie/emoji": "^4.1", "spatie/laravel-package-tools": "^1.14.0", "spatie/once": "^3.1" }, diff --git a/src/Commands/UpdatePermanentCachesCommand.php b/src/Commands/UpdatePermanentCachesCommand.php index 92fd29b..ad521b3 100644 --- a/src/Commands/UpdatePermanentCachesCommand.php +++ b/src/Commands/UpdatePermanentCachesCommand.php @@ -3,6 +3,8 @@ namespace Vormkracht10\PermanentCache\Commands; use Illuminate\Console\Command; +use ReflectionClass; +use Symfony\Component\Console\Helper\ProgressBar; use Vormkracht10\PermanentCache\Facades\PermanentCache; class UpdatePermanentCachesCommand extends Command @@ -26,8 +28,28 @@ class UpdatePermanentCachesCommand extends Command */ public function handle() { - $caches = PermanentCache::configuredCaches(); + $caches = collect( + PermanentCache::configuredCaches() + ); - $this->withProgressBar($caches, fn ($cache) => $cache->update()); + ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %message%'); + + $progressBar = $this->output->createProgressBar($caches->count()); + + $progressBar->setFormat('custom'); + + $progressBar->setMessage('Starting...'); + + $progressBar->start(); + + $caches->each(function ($cache) use ($progressBar) { + $cache->update(); + + $progressBar->setMessage('Updating: '.(new ReflectionClass($cache))->getName()); + $progressBar->advance(); + }); + + $progressBar->setMessage('Finished!'); + $progressBar->finish(); } }