diff options
| author | Julian Hurst <ark@mansus.space> | 2024-11-15 01:32:41 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2024-11-15 01:47:29 +0100 |
| commit | 373ed8172d62b84df70fee9c7f92658e203bb621 (patch) | |
| tree | f073bc554d99c0859e9cad8f8e6870c6bc615cc3 | |
| parent | 86ef1210a686bce0db3ead2760bf4d401e23883a (diff) | |
| download | hatask-373ed8172d62b84df70fee9c7f92658e203bb621.tar.gz | |
Add -a flag to add a task
| -rw-r--r-- | cmd.ha | 16 | ||||
| -rw-r--r-- | hatask.ha | 2 |
2 files changed, 18 insertions, 0 deletions
@@ -32,6 +32,10 @@ const commands: [_]command = [ func = &show, }, command { + names = ["a", "add"], + func = &add, + }, + command { names = ["w", "write"], func = &write, }, @@ -55,6 +59,18 @@ fn execcommand(cfg: config, name: str, tasks: []task, args: arguments) (void | e }; }; +fn add(cfg: config, tasks: []task, a: arguments) (void | task | error) = { + const args = a.args; + if (len(args) != 1z) { + getopt::printhelp(os::stderr, "write", a.help)?; + return; + }; + + let buf = path::init(cfg.tasksdir, args[0])?; + const c = exec::cmd("vim", path::string(&buf))?; + exec::exec(&c); +}; + fn write(cfg: config, tasks: []task, a: arguments) (void | task | error) = { const args = a.args; if (len(args) != 1z) { @@ -128,6 +128,8 @@ export fn main() void = { ("f", ["filter tasks", "id"]: []getopt::help), ("show", ["show task details", "id"]: []getopt::help), ("s", ["show task details", "id"]: []getopt::help), + ("add", ["add a task", "id"]: []getopt::help), + ("a", ["add a task", "id"]: []getopt::help), ("write", ["write a task", "id"]: []getopt::help), ("w", ["write a task", "id"]: []getopt::help), ("done", ["delete a task", "id"]: []getopt::help), |
