diff options
| author | Autumn | 2026-08-23 11:44:35 +0100 |
|---|---|---|
| committer | Autumn | 2026-08-23 11:44:35 +0100 |
| commit | 4708d5e010f8e787a06d2ec3361d70756d03d75f (patch) | |
| tree | f2937193437394ae2464543696675f59936b83c3 /main.ha | |
| parent | 6337a8d398a223345e2e22ede0911d5e6dcab019 (diff) | |
[bunnytask] added config file support
Diffstat (limited to 'main.ha')
| -rw-r--r-- | main.ha | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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) { |
