-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.php
57 lines (51 loc) · 1.6 KB
/
run.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
48
49
50
51
52
53
54
55
56
57
<?php
/** Advent of Code 2022 PHP runner.
*
* Usage:
* php run.php <options>
* -d,--day PATTERN Only run days that match pattern (range or comma-separated list)
* -p,--part PATTERN Only run parts that match pattern (range or comma-separated list)
* -e,--examples Runs the examples
* -h,--help This help message
*
* php run.php --day=[day] --part=[part] --examples
* [day] = optional - The day(s) to run. Can be a range (1-10) or comma-separated (1,2,5) including combination of both.
* [part] = optional - The part to run
* [withExamples] = optional - Will run the examples if defined in the Day class
*
* Examples:
* php run.php
* - Run all days
*
* php run.php --day=15 --examples
* - Run day 15 examples
*
* php run.php --day=1-5,9
* - Run days 1-5 & 9
*
* php run.php --day=10
* - Run day 10 part 1 & 2
*
* php run.php --day=6,7 --part=2
* - Run days 6 & 7 part 2
*
* php run.php --day=1-25 --examples
* - Run days 1-25 with examples
*/
declare(strict_types=1);
use App\DayFactory;
use App\Runner\DTO\CliArg;
use App\Runner\DTO\CliArgType;
use App\Runner\ParseCliArgs;
use App\Runner\Runner;
require 'vendor/autoload.php';
$cliArgs = [
new CliArg(longName: 'day', type: CliArgType::WITH_VALUE),
new CliArg(longName: 'part', type: CliArgType::WITH_VALUE),
new CliArg('examples', type: CliArgType::NO_VALUE),
new CliArg('help', type: CliArgType::NO_VALUE),
];
$cli = new ParseCliArgs(...$cliArgs);
$options = $cli->getOptions();
$runner = new Runner($options, new DayFactory());
$runner->run();