This repository has been archived by the owner on Dec 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.php
50 lines (43 loc) · 1.44 KB
/
cli.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once "vendor/autoload.php";
use Garden\Cli\Cli;
use pwnstar\AdventOfCode2020\Advent;
$cli = new Cli();
$advent = new Advent();
$cli->command('run')
->description('Run Advent of Code 2020 Challenges')
->opt('day:d', 'Specify a day to run/test', false, 'integer')
->command('test')
->description('Test Advent of Code 2020 Challenges')
->opt('day:d', 'Specify a day to run/test', false, 'integer');
try {
$args = $cli->parse($argv, true);
} catch (Exception $e) {
}
if (isset($args)) {
switch ($args->getCommand()) {
case 'run':
if (!empty($args->getOpt('day'))) {
$advent->runDay($args->getOpt('day'));
} else {
$doneDays = 6;
for ($i = 1; $i <= $doneDays; $i++) {
$advent->runDay($i);
}
}
break;
case 'test':
if (!empty($args->getOpt('day'))) {
$day = 'Day' . sprintf('%02d', $args->getOpt('day'));
echo "*** TESTING DAY $day ***" . PHP_EOL;
system("\"vendor/bin/phpunit\" --testdox advent/{$day}/{$day}Test.php");
} else {
$doneDays = 6;
for ($i = 1; $i <= $doneDays; $i++) {
$day = 'Day' . sprintf('%02d', $i);
system("\"vendor/bin/phpunit\" --testdox advent/{$day}/{$day}Test.php");
}
}
break;
}
}