diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2025-01-15 18:08:44 +0100 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2025-01-15 18:31:21 +0100 |
| commit | 0490236116c4fcf80563251e4175dbcc78e05787 (patch) | |
| tree | 4c702a8c0de8840984c3dd969da4827e3135476b /hatask.ha | |
| parent | 4129e3dba2cc3953af6b97fc1c99a1516b9214cd (diff) | |
| download | hatask-0490236116c4fcf80563251e4175dbcc78e05787.tar.gz | |
Add get command to get misc properties from tasks
Unknown entries in the task metadata are now added to a misc map and can be
gotten via the get command.
Diffstat (limited to 'hatask.ha')
| -rw-r--r-- | hatask.ha | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -15,6 +15,7 @@ use sort; use fnmatch; use errors; use time; +use map; type task = struct { name: str, @@ -22,6 +23,7 @@ type task = struct { context: (str | void), tags: []str, priority: uint, + misc: map::map, content: str, lmd: time::instant, }; @@ -84,6 +86,7 @@ fn readtask(taskpath: str) (task | rtaskerror) = { context = void, tags = [], lmd = stat.mtime, + misc = map::newmap(), ... }; for (let entry: ini::entry => ini::next(&isc)?) { @@ -95,7 +98,7 @@ fn readtask(taskpath: str) (task | rtaskerror) = { case "tags" => t.tags = strings::dupall(strings::split(entry.2, ",")); case => - void; + map::put(&t.misc, entry.1, entry.2); }; }; if (t.name == "") { @@ -114,6 +117,7 @@ fn freetask(t: *task) void = { free(t.context as str); }; strings::freeall(t.tags); + map::finishmap(&t.misc); }; fn finishall(tasks: []task) void = { @@ -201,6 +205,8 @@ export fn main() void = { ("d", ["delete a task", "id"]: []getopt::help), ("tsv", ["print tsv of tasks"]: []getopt::help), ("t", ["print tsv of tasks"]: []getopt::help), + ("get", ["get a misc property of a task", "[id]", "[key]"]: []getopt::help), + ("g", ["get a misc property of a task", "[id]", "[key]"]: []getopt::help), ); defer getopt::finish(&cmd); |
