forked from S-ecki/AdventOfCode-Starter-Dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
58 lines (49 loc) · 987 Bytes
/
main.dart
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
58
import 'solutions/index.dart';
import 'utils/generic_day.dart';
/// List holding all the solution classes.
final days = <GenericDay>[
Day01(),
Day02(),
Day03(),
Day04(),
Day05(),
Day06(),
Day07(),
Day08(),
Day09(),
Day10(),
Day11(),
Day12(),
Day14(),
];
void main(List<String?> args) {
bool onlyShowLast = true;
if (args.length == 1 && args[0].isHelperArgument()) {
printHelper();
return;
}
if (args.length == 1 && args[0].isAllArgument()) {
onlyShowLast = false;
}
onlyShowLast
? days.last.printSolutions()
: days.forEach((day) => day.printSolutions());
}
void printHelper() {
print(
'''
Usage: dart main.dart <command>
Global Options:
-h, --help Show this help message
-a, --all Show all solutions
''',
);
}
extension ArgsMatcher on String? {
bool isHelperArgument() {
return this == '-h' || this == '--help';
}
bool isAllArgument() {
return this == '-a' || this == '--all';
}
}