<?php

namespace App\Console\Commands;

use App\Domain\Training\Services\SessionGeneratorService;
use Illuminate\Console\Command;

class GenerateUpcomingSessions extends Command
{
    protected $signature = 'sessions:generate-upcoming {--days=7 : Number of days ahead to generate}';
    protected $description = 'Generate training sessions from group schedules for the upcoming period';

    public function handle(SessionGeneratorService $service): int
    {
        $days = (int) $this->option('days');
        $count = $service->generateUpcoming($days);

        if ($count > 0) {
            $this->info("Generated {$count} upcoming sessions for the next {$days} days.");
        } else {
            $this->info("No new sessions to generate.");
        }

        return self::SUCCESS;
    }
}
