diff options
Diffstat (limited to 'cmd.ha')
| -rw-r--r-- | cmd.ha | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -8,6 +8,7 @@ use os::exec; use strconv; use ascii; use format::tsv; +use map; type error = !(!str | io::error | path::error | exec::error | strconv::error); @@ -47,6 +48,10 @@ const commands: [_]command = [ names = ["t", "tsv"], func = &tsv, }, + command { + names = ["g", "get"], + func = &getmisc, + }, ]; fn execcommand(cfg: config, name: str, tasks: []task, args: arguments) (void | error) = { @@ -223,6 +228,40 @@ fn tsv(cfg: config, tasks: []task, a: arguments) (void | task | error) = { }; }; +fn getmisc(cfg: config, tasks: []task, a: arguments) (void | task | error) = { + const args = a.args; + if (len(args) == 0) { + for (let task .. tasks) { + const it = map::newiterator(task.misc); + for (let misc => map::next(&it)) { + fmt::printfln("{}: {}", misc.key, misc.val)!; + }; + }; + } else if (len(args) == 1) { + const id = strconv::stoz(a.args[0])?; + if (id >= len(tasks)) { + return "No such task"; + }; + const task = tasks[id]; + const it = map::newiterator(task.misc); + for (let misc => map::next(&it)) { + fmt::printfln("{}: {}", misc.key, misc.val)!; + }; + } else { + const id = strconv::stoz(args[0])?; + if (id >= len(tasks)) { + return "No such task"; + }; + const task = tasks[id]; + match (map::get(task.misc, args[1])) { + case void => + return "No such misc property"; + case let val: str => + fmt::printfln("{}: {}", args[1], val)!; + }; + }; +}; + fn listall(cfg: config, tasks: []task) void = { const headpad = PADDING - len("name") + len("priority"); const namepad = 10 - len("id") + len("name"); |
