mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-08 19:06:36 +00:00
--font-family CLI config
This commit is contained in:
@@ -60,6 +60,8 @@ pub fn parse(comptime T: type, alloc: Allocator, dst: *T, iter: anytype) !void {
|
||||
try parseIntoField(T, arena_alloc, dst, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (@hasDecl(T, "finalize")) try dst.finalize();
|
||||
}
|
||||
|
||||
/// Parse a single key/value pair into the destination type T.
|
||||
@@ -193,6 +195,28 @@ test "parse: simple" {
|
||||
try testing.expect(!data.@"b-f");
|
||||
}
|
||||
|
||||
test "parse: finalize" {
|
||||
const testing = std.testing;
|
||||
|
||||
var data: struct {
|
||||
a: []const u8 = "",
|
||||
_arena: ?ArenaAllocator = null,
|
||||
|
||||
pub fn finalize(self: *@This()) !void {
|
||||
self.a = "YO";
|
||||
}
|
||||
} = .{};
|
||||
defer if (data._arena) |arena| arena.deinit();
|
||||
|
||||
var iter = try std.process.ArgIteratorGeneral(.{}).init(
|
||||
testing.allocator,
|
||||
"--a=42",
|
||||
);
|
||||
defer iter.deinit();
|
||||
try parse(@TypeOf(data), testing.allocator, &data, &iter);
|
||||
try testing.expectEqualStrings("YO", data.a);
|
||||
}
|
||||
|
||||
test "parseIntoField: string" {
|
||||
const testing = std.testing;
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
|
Reference in New Issue
Block a user