2021-12-01 22:46:07 +01:00
|
|
|
<?php
|
|
|
|
|
2021-12-09 22:41:22 +01:00
|
|
|
namespace trizz\AdventOfCode;
|
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;
|
2021-12-09 22:25:59 +00:00
|
|
|
use trizz\AdventOfCode\Utils\SymfonyConsoleMarkdown;
|
2021-12-01 22:46:07 +01:00
|
|
|
|
|
|
|
class Puzzle extends Command
|
|
|
|
{
|
|
|
|
protected function configure(): void
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setName('puzzle')
|
2021-12-09 22:41:22 +01:00
|
|
|
->addArgument('day', InputArgument::REQUIRED, 'The day number.')
|
|
|
|
->addArgument('year', InputArgument::OPTIONAL, 'The year', date('y'));
|
2021-12-01 22:46:07 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2021-12-09 22:41:22 +01:00
|
|
|
$contents = file_get_contents(
|
|
|
|
sprintf(
|
|
|
|
'%s/../data/Y%d/day%s/puzzle.md',
|
|
|
|
__DIR__,
|
|
|
|
$input->getArgument('year'),
|
|
|
|
(int) $input->getArgument('day')
|
|
|
|
)
|
|
|
|
);
|
2021-12-01 22:46:07 +01:00
|
|
|
$rendered = (new SymfonyConsoleMarkdown())->render($contents);
|
|
|
|
|
|
|
|
$output->writeln($rendered);
|
|
|
|
|
|
|
|
return Command::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|