diff --git a/bin/adventofcode2025.dart b/bin/adventofcode2025.dart index 5043c7b..1980214 100644 --- a/bin/adventofcode2025.dart +++ b/bin/adventofcode2025.dart @@ -1,6 +1,7 @@ import 'package:adventofcode2025/day1/command.dart' as day1; import 'package:adventofcode2025/day2/command.dart' as day2; import 'package:adventofcode2025/day3/command.dart' as day3; +import 'package:adventofcode2025/day4/command.dart' as day4; import 'package:args/command_runner.dart'; @@ -9,5 +10,6 @@ void main(List arguments) { ..addCommand(day1.Day1Command()) ..addCommand(day2.Day2Command()) ..addCommand(day3.Day3Command()) + ..addCommand(day4.Day4Command()) ..run(arguments); } diff --git a/lib/day1/command.dart b/lib/day1/command.dart index 2f8ed75..656eafa 100644 --- a/lib/day1/command.dart +++ b/lib/day1/command.dart @@ -58,6 +58,7 @@ class Day1Command extends Command { print( "Expected 1 positional arguments, found ${argResults!.rest.length}", ); + exit(1); } var fileName = argResults!.rest[0]; diff --git a/lib/day2/command.dart b/lib/day2/command.dart index 52baa02..f118b28 100644 --- a/lib/day2/command.dart +++ b/lib/day2/command.dart @@ -26,6 +26,7 @@ class Day2Command extends Command { print( "Expected 1 positional arguments, found ${argResults!.rest.length}", ); + exit(1); } var filePath = argResults!.rest[0]; diff --git a/lib/day3/command.dart b/lib/day3/command.dart index cb85e6a..85119af 100644 --- a/lib/day3/command.dart +++ b/lib/day3/command.dart @@ -27,6 +27,7 @@ class Day3Command extends Command { print( "Expected 1 positional arguments, found ${argResults!.rest.length}", ); + exit(1); } var filePath = argResults!.rest[0]; diff --git a/lib/day4/command.dart b/lib/day4/command.dart new file mode 100644 index 0000000..69afc21 --- /dev/null +++ b/lib/day4/command.dart @@ -0,0 +1,36 @@ +import "dart:convert"; +import "dart:io"; + +import "package:args/command_runner.dart"; + +class Day4Command extends Command { + // The [name] and [description] properties must be defined by every + // subclass. + @override + final name = "day4"; + + @override + final description = "Run Advent of Code 2025 Day 3"; + + Day4Command() { + // we can add command specific arguments here. + // [argParser] is automatically created by the parent class. + } + + // [run] may also return a Future. + @override + Future 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"); + } +}