diff options
| author | Julian Hurst <ark@mansus.space> | 2024-11-15 03:09:58 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2024-11-15 03:11:19 +0100 |
| commit | e0976a8c3f307d412d425c501c219d622a85555e (patch) | |
| tree | 8750195076f52596be696fc2d519f5d691ff88fe /hatask.ha | |
| parent | 7d984cbd69b92470dad43bd8783c01a3abbd6b84 (diff) | |
| download | hatask-e0976a8c3f307d412d425c501c219d622a85555e.tar.gz | |
Support an ini config file
Diffstat (limited to 'hatask.ha')
| -rw-r--r-- | hatask.ha | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -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)); |
