argument('project'); $token = $this->option('token'); // 如果 role 选项未提供(为空),提示用户输入 if (empty($token)) { $token = $this->ask('Please enter the user token:'); } $status = $this->choice( 'Which framework do you prefer?', ['published', 'restarted', 'stop'], 0 // 默认选择 Laravel(索引 0) ); $response = Http::withToken($token) ->get($appUrl . "/api/v2/task?view=project&project_id={$projectId}&status=all&order=order&dir=asc"); if ($response->failed()) { $this->error('task read fail' . $response->json('message')); Log::error('task read fail', ['data' => $response->body()]); return 1; } $tasks = $response->json()['data']['rows']; foreach ($tasks as $key => $task) { $this->info("[{$key}]task " . $task['title'] . ' status ' . $task['status']); $response = Http::withToken($token) ->patch($appUrl . "/api/v2/task-status/" . $task['id'], ['status' => $status]); if ($response->failed()) { $this->error('task status fail' . $response->json('message')); Log::error('task status fail', ['data' => $response->body()]); } $this->info("[{$key}]task status changed {$status}"); } return 0; } }