46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
import "dart:convert";
|
|
import "dart:io";
|
|
|
|
import "package:args/command_runner.dart";
|
|
|
|
class Day5Command extends Command {
|
|
// The [name] and [description] properties must be defined by every
|
|
// subclass.
|
|
@override
|
|
final name = "day5";
|
|
|
|
@override
|
|
final description = "Run Advent of Code 2025 Day 5";
|
|
|
|
Day5Command() {
|
|
// we can add command specific arguments here.
|
|
// [argParser] is automatically created by the parent class.
|
|
}
|
|
|
|
// [run] may also return a Future.
|
|
@override
|
|
Future<void> run() async {
|
|
// [argResults] is set before [run()] is called and contains the flags/options
|
|
// passed to this command.
|
|
|
|
if (argResults!.rest.length != 1) {
|
|
print(
|
|
"Expected 1 positional arguments, found ${argResults!.rest.length}",
|
|
);
|
|
exit(1);
|
|
}
|
|
var filePath = argResults!.rest[0];
|
|
|
|
print("Parsing file: $filePath");
|
|
var inputFile = File(filePath);
|
|
var result = await inputFile
|
|
.openRead()
|
|
.transform(utf8.decoder)
|
|
.transform(LineSplitter())
|
|
.map((line) {
|
|
return line;
|
|
})
|
|
.toList();
|
|
}
|
|
}
|