<?php

declare(strict_types=1);

namespace App\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(name: 'bot:info', description: 'GET /me — print BotInfo.')]
final class GetBotInfoCommand extends AbstractCommand
{

    protected function doExecute(SymfonyStyle $io, InputInterface $input, OutputInterface $output): int
    {
        $info = $this->api->bots->getBot();
        $io->text('name: ' . $info->name);
        $io->text('username: @' . ($info->username ?? '—'));
        $io->text('user_id: ' . $info->userId);
        $io->text('description: ' . ($info->description ?? '—'));
        $io->text('commands:');
        foreach ($info->commands as $c) {
            $io->text("  /{$c->name} — {$c->description}");
        }
        return self::SUCCESS;
    }
}
