<?php

namespace App\Command;

use App\Message\TriggerPriceImport;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Messenger\MessageBusInterface;

#[AsCommand(
    name: 'mto:test:trigger-import',
    description: 'Dispatches a TriggerPriceImport message for testing'
)]
class TriggerTestCommand extends Command
{
    public function __construct(
        private readonly MessageBusInterface $bus
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $timestamp = date('YmdHis');
        $output->writeln("Dispatching TriggerPriceImport with timestamp: $timestamp");

        $this->bus->dispatch(new TriggerPriceImport($timestamp));

        $output->writeln("Message dispatched. Check Redis stream 'messages'.");
        return Command::SUCCESS;
    }
}
