option('from') ?: '2024-01-01'); $to = (string) ($this->option('to') ?: now()->toDateString()); $stocksDate = (string) ($this->option('stocks-date') ?: now()->toDateString()); $endpoint = $this->option('endpoint') ? (string) $this->option('endpoint') : null; $this->info('WB API sync started'); $this->line("Period: {$from} - {$to}"); $this->line("Stocks date: {$stocksDate}"); $this->newLine(); $progress = function (string $endpoint, int $page, int $items, int $total, bool $finished): void { if ($finished) { $this->line(sprintf('%s page=%d empty, total=%d, finished', $endpoint, $page, $total)); return; } $this->line(sprintf('%s page=%d items=%d total=%d', $endpoint, $page, $items, $total)); }; $result = $syncService->syncAll($from, $to, $stocksDate, $endpoint, $progress); $this->newLine(); $this->info('WB API sync finished'); foreach ($result as $name => $count) { $this->line("{$name}: {$count} item(s) processed"); } return self::SUCCESS; } }