diff options
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)!; +}; |
