const std = @import("std"); const print = std.debug.print; const day01 = @import("src/day01.zig"); const day02 = @import("src/day02.zig"); const Day = enum { day01, day02 }; pub fn main() !void { if (std.os.argv.len != 3) { print("Usage: {s} < \n", .{std.os.argv[0]}); return; } const stdin = std.io.getStdIn(); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); defer { _ = gpa.deinit(); } const stat = try stdin.stat(); const buffer = try stdin.readToEndAlloc(allocator, stat.size); defer allocator.free(buffer); const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); const day = std.meta.stringToEnum(Day, args[1]) orelse { print("Not valid day or day not yet implemented\n: {s}", .{args[1]}); return; }; try switch (day) { .day01 => day01.solve(args[2], buffer, allocator), .day02 => day02.solve(args[2], buffer), }; }