-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
31 lines (24 loc) · 697 Bytes
/
create.php
File metadata and controls
31 lines (24 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use Dotenv\Dotenv;
use Knevelina\AdventOfCode\PuzzleInputRetriever;
use Knevelina\AdventOfCode\PuzzleSolverCreator;
require_once __DIR__.'/vendor/autoload.php';
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
$year = intval(date('Y'));
$day = intval(date('j'));
if ($argc === 3) {
$year = intval($argv[1]);
$day = intval($argv[2]);
} elseif ($argc === 2) {
$day = intval($argv[1]);
}
try {
PuzzleSolverCreator::createPuzzle($year, $day);
if (! empty($_ENV['SESSION_COOKIE'])) {
PuzzleInputRetriever::retrievePuzzleInput($year, $day);
}
} catch (RuntimeException|InvalidArgumentException $e) {
echo $e->getMessage();
exit(1);
}