option('preview'); $importer->setDefaultVpsProductId((int) $this->option('default-product')); $map = []; foreach ((array) $this->option('map') as $pair) { if (! str_contains($pair, ':')) continue; [$legacy, $new] = explode(':', $pair, 2); $map[(int) $legacy] = (int) $new; } if ($map) { $importer->setProductMap($map); $this->info('Product map: ' . json_encode($map)); } if (! $preview && ! $this->confirm('This will write to the current DB. Continue?', true)) { $this->warn('Aborted.'); return self::SUCCESS; } try { $summary = $importer->import( preview: $preview, log: fn ($msg) => $this->line($msg), ); } catch (\Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; } $this->newLine(); $this->info('=== Summary ==='); foreach ($summary as $section => $stats) { $this->line(str_pad(ucfirst($section), 12) . ': ' . json_encode($stats)); } return self::SUCCESS; } }