Setup command for day 3
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:adventofcode2025/day1/command.dart' as day1;
|
import 'package:adventofcode2025/day1/command.dart' as day1;
|
||||||
import 'package:adventofcode2025/day2/command.dart' as day2;
|
import 'package:adventofcode2025/day2/command.dart' as day2;
|
||||||
|
import 'package:adventofcode2025/day3/command.dart' as day3;
|
||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
|
|
||||||
@@ -7,5 +8,6 @@ void main(List<String> arguments) {
|
|||||||
CommandRunner("adventofcode2025", "Advent of Code 2025 solutions")
|
CommandRunner("adventofcode2025", "Advent of Code 2025 solutions")
|
||||||
..addCommand(day1.Day1Command())
|
..addCommand(day1.Day1Command())
|
||||||
..addCommand(day2.Day2Command())
|
..addCommand(day2.Day2Command())
|
||||||
|
..addCommand(day3.Day3Command())
|
||||||
..run(arguments);
|
..run(arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
36
lib/day3/command.dart
Normal file
36
lib/day3/command.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import "dart:io";
|
||||||
|
|
||||||
|
import "package:args/command_runner.dart";
|
||||||
|
|
||||||
|
class Day3Command extends Command {
|
||||||
|
// The [name] and [description] properties must be defined by every
|
||||||
|
// subclass.
|
||||||
|
@override
|
||||||
|
final name = "day3";
|
||||||
|
|
||||||
|
@override
|
||||||
|
final description = "Run Advent of Code 2025 Day 3";
|
||||||
|
|
||||||
|
Day3Command() {
|
||||||
|
// 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}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
var filePath = argResults!.rest[0];
|
||||||
|
|
||||||
|
print("Parsing file: $filePath");
|
||||||
|
|
||||||
|
var inputFile = File(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user