From e2ad2e09a8fd360640ec302e347e9ea8276bf618 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Fri, 15 Nov 2024 22:11:00 +0100 Subject: Add debug to config and improve printconfig --- config.ha | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'config.ha') diff --git a/config.ha b/config.ha index f16ecc3..df722ad 100644 --- a/config.ha +++ b/config.ha @@ -11,6 +11,7 @@ type config = struct { tasksdir: str, context: str, tags: []str, + debug: bool, }; type cerror = !(fs::error | path::error | ini::error); @@ -26,6 +27,7 @@ fn readconfig() (config | cerror) = { tasksdir = strings::dup("tasks"), context = strings::dup("*"), tags = [], + debug = false, }; for (const en => ini::next(&sc)?) { switch (en.1) { @@ -35,6 +37,8 @@ fn readconfig() (config | cerror) = { c.context = strings::dup(strings::trim(en.2)); case "tags" => c.tags = strings::dupall(strings::split(strings::trim(en.2), ",")); + case "debug" => + c.debug = en.2 == "true"; case => void; }; @@ -62,9 +66,9 @@ fn strcerror(e: cerror) str = { }; fn printconfig(cfg: config) void = { - fmt::errorln(cfg.tasksdir)!; - fmt::errorln(cfg.context)!; - for (const tag .. cfg.tags) { - fmt::errorln(tag)!; - }; + fmt::errorfln("tasksdir: {}", cfg.tasksdir)!; + fmt::errorfln("context: {}", cfg.context)!; + const stags = strings::join(",", cfg.tags...); + defer free(stags); + fmt::errorfln("tags: {}", stags)!; }; -- cgit v1.2.3