aboutsummaryrefslogtreecommitdiff
path: root/main.ha
diff options
context:
space:
mode:
authorAutumn2026-08-23 11:44:35 +0100
committerAutumn2026-08-23 11:44:35 +0100
commit4708d5e010f8e787a06d2ec3361d70756d03d75f (patch)
treef2937193437394ae2464543696675f59936b83c3 /main.ha
parent6337a8d398a223345e2e22ede0911d5e6dcab019 (diff)
[bunnytask] added config file support
Diffstat (limited to 'main.ha')
-rw-r--r--main.ha22
1 files changed, 17 insertions, 5 deletions
diff --git a/main.ha b/main.ha
index 995d5d4..7833db8 100644
--- a/main.ha
+++ b/main.ha
@@ -1,17 +1,29 @@
use fmt;
+use fs;
+use lib;
use strings;
use todo;
-use fs;
-
-def TODO_FILE = "todo.txt";
export fn main() void = {
- const todos = match(todo::open(TODO_FILE)) {
+
+ // load config
+ const config = match (lib::config_read()) {
+ case let config: *lib::config => yield config;
+ case let err: fs::error => fmt::fatalf("Error opening config: {}", fs::strerror(err));
+ };
+ defer lib::config_free(config);
+
+ // TODO handle multiple todo files
+ const todo_file = config.files[0];
+
+ // load todos
+ const todos = match (todo::open(todo_file)) {
case let todos: []str => yield todos;
- case let err: fs::error => fmt::fatalf("Error opening {}: {}", TODO_FILE, fs::strerror(err));
+ case let err: fs::error => fmt::fatalf("Error opening {}: {}", todo_file, fs::strerror(err));
};
defer strings::freeall(todos);
+ // print todos
fmt::println("To-dos:")!;
for (let item .. todos) {