const std = @import("std"); const debug = @import("std").debug; const out = @import("output.zig"); pub const OutputConfig = union(enum) { window: out.WindowOutput.Config, texture_share_vk: out.TSVOutput.Config, const default: OutputConfig = .{ .window = .default }; }; fn parseInt(it: *std.process.ArgIterator, comptime T: type) !T { const value = it.next() orelse return error.missingArgument; return try std.fmt.parseInt(T, value, 10); } fn parseString(it: *std.process.ArgIterator, allocator: std.mem.Allocator) ![]u8 { const value = it.next() orelse return error.missingArgument; return allocator.dupe(u8, value); } pub const Config = struct { width: i32, height: i32, outputs: []const OutputConfig, osc: []const u8, pub const default: Config = .{ .width = 1920, .height = 1080, .outputs = ([_]OutputConfig{.default})[0..], .osc = "osc.udp://:9000", }; pub fn init(allocator: std.mem.Allocator) !Config { var config: Config = .default; var it = try std.process.argsWithAllocator(allocator); defer it.deinit(); _ = it.skip(); while (it.next()) |arg| { if (std.mem.eql(u8, arg, "--width")) { config.width = try parseInt(&it, i32); } else if (std.mem.eql(u8, arg, "--height")) { config.height = try parseInt(&it, i32); } else if (std.mem.eql(u8, arg, "--osc")) { config.osc = try parseString(&it, allocator); } else { return error.invalidArgument; } // @TODO: output config } return config; } };