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) {
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
int calculate() {
|
|
||||||
return 6 * 7;
|
|
||||||
}
|
|
||||||
3
lib/day1/main.dart
Normal file
3
lib/day1/main.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
void run() {
|
||||||
|
print("Hello World Day 1");
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "8.1.1"
|
version: "8.1.1"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ environment:
|
|||||||
|
|
||||||
# Add regular dependencies here.
|
# Add regular dependencies here.
|
||||||
dependencies:
|
dependencies:
|
||||||
|
args: ^2.7.0
|
||||||
# path: ^1.8.0
|
# path: ^1.8.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user