Load $XDG_CONFIG_HOME/ghostty/config if it exists (#25)

Ghostty now loads the config file in `$XDG_CONFIG_HOME/ghostty/config` if it exists on startup. This follows the XDG base dir specification so if $XDG_CONFIG_HOME is not set, we default to `$HOME/.config/ghostty/config`.
This commit is contained in:
Mitchell Hashimoto
2022-11-02 16:12:50 -07:00
committed by GitHub
parent 116a157e17
commit d75e869b4e
4 changed files with 197 additions and 35 deletions

View File

@@ -60,8 +60,6 @@ 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.
@@ -195,28 +193,6 @@ 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);