adventofcode/src/Puzzle.php

33 lines
902 B
PHP
Raw Normal View History

2021-12-01 22:46:07 +01:00
<?php
namespace trizz\AdventOfCode;
2021-12-01 22:46:07 +01:00
use trizz\AdventOfCode\Utils\SymfonyConsoleMarkdown;
2021-12-01 22:46:07 +01:00
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.');
}
2021-12-06 23:39:16 +01:00
/**
* @return int
*/
2021-12-01 22:46:07 +01:00
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;
}
}