diff options
| author | Autumn | 2026-08-23 11:33:35 +0100 |
|---|---|---|
| committer | Autumn | 2026-08-23 11:33:35 +0100 |
| commit | 6337a8d398a223345e2e22ede0911d5e6dcab019 (patch) | |
| tree | 297121cbda8bf765d9d9cd64b1d31fd850882900 /todo | |
| parent | 47a3890c0055e04ffba2984f1870452cb1653435 (diff) | |
[bunnytask] added basic TODO.TXT reading
Diffstat (limited to 'todo')
| -rw-r--r-- | todo/open.ha | 23 | ||||
| -rw-r--r-- | todo/print.ha | 5 |
2 files changed, 28 insertions, 0 deletions
diff --git a/todo/open.ha b/todo/open.ha new file mode 100644 index 0000000..7692635 --- /dev/null +++ b/todo/open.ha @@ -0,0 +1,23 @@ +use fs; +use io; +use lib; +use os; +use strings; + +export fn open(file: str) ([]str | fs::error) = { + + // open + const todos = os::open(file)?; + defer io::close(todos)!; + + const todos = io::drain(todos)!; + defer free(todos); + + // read + const todos = strings::fromutf8(todos)!; + const todos = strings::split(todos, "\n")!; + + lib::slice_remove_empty(&todos); + + return strings::dupall(todos)?; +}; diff --git a/todo/print.ha b/todo/print.ha new file mode 100644 index 0000000..4106fd9 --- /dev/null +++ b/todo/print.ha @@ -0,0 +1,5 @@ +use fmt; + +export fn print(todo: str) void = { + fmt::printfln("* {}", todo)!; +}; |
