diff options
Diffstat (limited to 'cmd.ha')
| -rw-r--r-- | cmd.ha | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -14,7 +14,6 @@ type func = fn(tasks: []task, args: arguments) (void | task | error); type command = struct { names: []str, - help: []getopt::help, func: *func, }; @@ -25,19 +24,20 @@ const PADDING: size = 30z; const commands: [_]command = [ command { names = ["f", "filter"], - help = ["<name>"], func = &filter, }, command { names = ["s", "show"], - help = ["<id>"], func = &show, }, command { names = ["w", "write"], - help = ["<id>"], func = &write, }, + command { + names = ["d", "done"], + func = &do, + }, ]; fn execcommand(name: str, tasks: []task, args: arguments) (void | error) = { @@ -100,6 +100,17 @@ fn printtask(t: task, id: size) (void | error) = { )!; }; +fn do(tasks: []task, a: arguments) (void | task | error) = { + if (len(a.args) != 1z) { + getopt::printhelp(os::stderr, "done", a.help)?; + os::exit(os::status::FAILURE); + }; + const id = strconv::stoz(a.args[0])?; + const t = tasks[id]; + os::remove(t.path)?; + fmt::printfln("Task {}: \"{}\" done (deleted)", id, t.name)!; +}; + fn filter(tasks: []task, a: arguments) (void | task | error) = { const headpad = PADDING - len("name") + len("priority"); const namepad = 10 - len("id") + len("name"); |
