option('model') || !$this->option('channel') ) { $this->error('model,article,channel is requested'); return; } // // ===== 创建 Service ===== $service = app(ArticleTranslateService::class); // ===== 执行 ===== if ($this->option('article')) { $this->info('article translate start'); $total = $service->setModel($this->option('model')) ->setChannel($this->option('channel')) ->translateArticle($this->option('article')) ->save(); $this->info("{$total} sentences saved"); } if ($this->option('anthology')) { $this->info('anthology translate start'); $total = $service->setModel($this->option('model')) ->setChannel($this->option('channel')) ->translateAnthology($this->option('anthology'), function ($article, $sentences) { $this->info("translate article {$article} sentences {$sentences}"); }); $this->info("{$total} article saved"); } } }