adventofcode/src/Puzzle.php
2021-12-01 22:46:23 +01:00

30 lines
859 B
PHP

<?php
namespace AdventOfCode21;
use AdventOfCode21\Utils\SymfonyConsoleMarkdown;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Puzzle extends Command
{
protected function configure(): void
{
$this
->setName('puzzle')
->addArgument('day', InputArgument::REQUIRED, 'The day number.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$contents = file_get_contents(sprintf('%s/../data/day%s/puzzle.md', __DIR__, (int) $input->getArgument('day')));
$rendered = (new SymfonyConsoleMarkdown())->render($contents);
$output->writeln($rendered);
return Command::SUCCESS;
}
}