diff options
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) { |
