Setup framework for running days from single command
This commit is contained in:
@@ -1,5 +1,29 @@
|
||||
import 'package:adventofcode2025/adventofcode2025.dart' as adventofcode2025;
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:adventofcode2025/day1/main.dart' as day1;
|
||||
|
||||
import 'package:args/args.dart';
|
||||
|
||||
const help = 'help';
|
||||
const dayNumber = 'day';
|
||||
|
||||
void main(List<String> arguments) {
|
||||
print('Hello world: ${adventofcode2025.calculate()}!');
|
||||
final parser = ArgParser()
|
||||
..addFlag(help, negatable: false, abbr: 'h')
|
||||
..addOption(dayNumber, mandatory: true, abbr: "d");
|
||||
var results = parser.parse(arguments);
|
||||
|
||||
if (results.flag(help)) {
|
||||
print(parser.usage);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
var day = results.option(dayNumber);
|
||||
|
||||
switch (day) {
|
||||
case '1':
|
||||
day1.run();
|
||||
default:
|
||||
print("'$day' is not a valid value for option $dayNumber");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user