option('fresh')) { Cache::forget(self::CACHE_KEY); $this->info('Cleared cached progress.'); } $completedSteps = Cache::get(self::CACHE_KEY, []); $steps = [ 'para' => 'upgrade:progress.para', 'chapter' => 'upgrade:progress.chapter', ]; foreach ($steps as $key => $command) { if (in_array($key, $completedSteps)) { $this->info("Skipping [{$command}] (already completed)."); continue; } $this->info("Running [{$command}]..."); $exitCode = $this->call($command); if ($exitCode !== 0) { $this->error("[{$command}] failed with exit code {$exitCode}. Re-run to resume."); return $exitCode; } $completedSteps[] = $key; Cache::put(self::CACHE_KEY, $completedSteps, now()->addHours(48)); } Cache::forget(self::CACHE_KEY); $this->info('All steps completed.'); return 0; } }