<?php

namespace App\Shared\Logging\Command;

use App\Shared\Logging\LogPruneService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'app:prune-logs', description: 'حذف لاگ‌های قدیمی‌تر از مدت نگهداری تنظیم‌شده')]
final class PruneLogsCommand extends Command
{
    public function __construct(private readonly LogPruneService $pruneService)
    {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $deleted = $this->pruneService->pruneByRetention();
        $output->writeln(sprintf('%d لاگ حذف شد.', $deleted));

        return Command::SUCCESS;
    }
}
