aboutsummaryrefslogtreecommitdiff
path: root/hatask.ha
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2024-11-15 03:09:58 +0100
committerJulian Hurst <ark@mansus.space>2024-11-15 03:11:19 +0100
commite0976a8c3f307d412d425c501c219d622a85555e (patch)
tree8750195076f52596be696fc2d519f5d691ff88fe /hatask.ha
parent7d984cbd69b92470dad43bd8783c01a3abbd6b84 (diff)
downloadhatask-e0976a8c3f307d412d425c501c219d622a85555e.tar.gz
Support an ini config file
Diffstat (limited to 'hatask.ha')
-rw-r--r--hatask.ha24
1 files changed, 18 insertions, 6 deletions
diff --git a/hatask.ha b/hatask.ha
index c92f688..0d3374f 100644
--- a/hatask.ha
+++ b/hatask.ha
@@ -13,6 +13,7 @@ use encoding::utf8;
use getopt;
use sort;
use fnmatch;
+use errors;
type task = struct {
name: str,
@@ -157,22 +158,33 @@ export fn main() void = {
);
defer getopt::finish(&cmd);
- const cfg: config = config {
- tasksdir = "tasks",
- context = "*",
+ const cfg: config = match (readconfig()) {
+ case let cfg: config =>
+ yield cfg;
+ case let e: fs::error =>
+ match (e) {
+ case let e: errors::noentry =>
+ fmt::fatal("No config file found");
+ case =>
+ fmt::fatal(fs::strerror(e));
+ };
+ case let e: cerror =>
+ fmt::fatal(strcerror(e));
};
+ defer cfinish(&cfg);
+
+
for (let opt .. cmd.opts) {
switch (opt.0) {
case 'f' =>
- cfg.tasksdir = opt.1;
+ cfg.tasksdir = strings::dup(opt.1);
case 'c' =>
- cfg.context = opt.1;
+ cfg.context = strings::dup(opt.1);
case =>
abort();
};
};
-
const tasks = match (listtasks(cfg.tasksdir, cfg.context)) {
case let e: rtaskerror =>
fmt::fatal(strrtaskerror(e));