aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.ha14
-rw-r--r--hatask.ha6
2 files changed, 12 insertions, 8 deletions
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)!;
};
diff --git a/hatask.ha b/hatask.ha
index c227df8..4677b31 100644
--- a/hatask.ha
+++ b/hatask.ha
@@ -206,7 +206,6 @@ export fn main() void = {
defer cfinish(&cfg);
let sortfn: *sort::cmpfunc = &sortname;
- let debug = false;
for (let opt .. cmd.opts) {
switch (opt.0) {
case 'f' =>
@@ -218,13 +217,14 @@ export fn main() void = {
case 'p' =>
sortfn = &sortpriority;
case 'd' =>
- debug = true;
+ cfg.debug = true;
case =>
abort();
};
};
- if (debug) {
+ if (cfg.debug) {
+ fmt::errorln("config:")!;
printconfig(cfg);
};