rob-revisited/ide/tests/fixtures/wizard/send-report-classic.php

63 lines
2.1 KiB
PHP

<?php
namespace App\Command;
use App\Repository\UserRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'app:send-report',
description: 'Sends the report',
aliases: ['report'],
)]
final class SendReportCommand extends Command
{
public function __construct(
private readonly UserRepository $userRepository,
private readonly LoggerInterface $logger,
) {
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('user', InputArgument::REQUIRED, 'The user')
->addArgument('months', InputArgument::OPTIONAL, '', 3)
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Change nothing')
->addOption('format', 'f', InputOption::VALUE_REQUIRED, '', 'pdf')
->addOption('tag', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY)
->addOption('color', null, InputOption::VALUE_NEGATABLE)
->addOption('limit', null, InputOption::VALUE_OPTIONAL)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$user = $input->getArgument('user');
$months = $input->getArgument('months');
$dryRun = $input->getOption('dry-run');
$format = $input->getOption('format');
$tag = $input->getOption('tag');
$color = $input->getOption('color');
$limit = $input->getOption('limit');
$io->title('Report');
$go = $io->confirm('Send it?', false);
$io->table(['Id', 'Name'], [
['1', 'Ada'],
['2', 'Alan'],
]);
$io->success('Sent.');
return Command::SUCCESS;
}
}