chore: move TOML loading + parsing to it's own file
Unfortunately, this leaks memory. I should try using loadContents or perhaps I should try contributing some fixes upstream.
This commit is contained in:
parent
51115cba86
commit
584a1637ce
26
src/main.zig
26
src/main.zig
|
@ -43,11 +43,10 @@ pub fn main() anyerror!void {
|
|||
const save_path = try savePath(allocator, data_path);
|
||||
defer allocator.free(save_path);
|
||||
|
||||
// Read Config File
|
||||
log.info("Config File: {s}", .{config_path});
|
||||
const table = try toml.parseFile(allocator, config_path, null);
|
||||
defer table.deinit();
|
||||
log.info("{?}", .{table});
|
||||
const config = try loadConfig(allocator, config_path);
|
||||
_ = config;
|
||||
|
||||
log.debug("got past loadConfig()", .{});
|
||||
|
||||
// Handle CLI Input
|
||||
const result = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{});
|
||||
|
@ -93,6 +92,23 @@ pub fn handleArguments(allocator: Allocator, data_path: []const u8, result: *con
|
|||
};
|
||||
}
|
||||
|
||||
const Config = struct {
|
||||
// TODO: Add Config Fields
|
||||
// TODO: Move to it's own file? config.zig?
|
||||
};
|
||||
|
||||
// FIXME: TOML Library Leaks memory here
|
||||
// Either I should improve the TOML library, or try some of the even less used ones :thinking
|
||||
fn loadConfig(allocator: Allocator, config_path: []const u8) !Config {
|
||||
// _ = allocator;
|
||||
// _ = config_path;
|
||||
|
||||
const table = try toml.parseFile(allocator, config_path, null);
|
||||
table.deinit();
|
||||
|
||||
return .{};
|
||||
}
|
||||
|
||||
fn configFilePath(allocator: Allocator, data_path: []const u8) ![]const u8 {
|
||||
const path = try std.fs.path.join(allocator, &[_][]const u8{ data_path, "zba", "config.toml" });
|
||||
|
||||
|
|
Loading…
Reference in New Issue