aboutsummaryrefslogtreecommitdiff
path: root/cmd.ha
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2024-11-15 13:29:02 +0100
committerJulian Hurst <ark@mansus.space>2024-11-15 13:29:19 +0100
commitba38c9e073db90b530f2ba4460fb124a930ea055 (patch)
tree400febfaff84bceb2901d1fc6d00a99ad6406def /cmd.ha
parent77128923c2f1a65c723c653532d32dfe99d2f411 (diff)
downloadhatask-ba38c9e073db90b530f2ba4460fb124a930ea055.tar.gz
Support tags
Diffstat (limited to 'cmd.ha')
-rw-r--r--cmd.ha37
1 files changed, 29 insertions, 8 deletions
diff --git a/cmd.ha b/cmd.ha
index 1e520e6..cc81304 100644
--- a/cmd.ha
+++ b/cmd.ha
@@ -104,8 +104,10 @@ fn printtasktsv(cfg: config, t: task, id: size) (void | error) = {
defer free(sid);
const spriority = strconv::ztos(t.priority);
const buf = path::init(t.path)?;
+ const stags = strings::join(",", t.tags...);
+ defer free(stags);
const p = path::trimprefix(&buf, cfg.tasksdir)?;
- tsv::writerecord(os::stdout, [sid, t.name, spriority, p])!;
+ tsv::writerecord(os::stdout, [sid, t.name, spriority, stags, p])!;
};
fn printtask(cfg: config, t: task, id: size) (void | error) = {
@@ -115,12 +117,16 @@ fn printtask(cfg: config, t: task, id: size) (void | error) = {
name = strings::concat(strings::sub(t.name, 0z, PADDING - 4),
"...");
};
+
const pad = PADDING - len(name) + len(strconv::utos(t.priority));
const namepad = 10 - len(strconv::ztos(id)) + len(name);
const buf = path::init(t.path)?;
+ const stags = strings::join(",", t.tags...);
+ defer free(stags);
+ const tagspad = 15 - len(strconv::utos(t.priority)) + len(stags);
const p = path::trimprefix(&buf, cfg.tasksdir)?;
- const pathpad = 15 - len(strconv::utos(t.priority)) + len(p);
- fmt::printfln("{}{%}{%}{%}", id, name, &fmt::mods {
+ const pathpad = 20 - len(stags) + len(p);
+ fmt::printfln("{}{%}{%}{%}{%}", id, name, &fmt::mods {
pad = ' ',
width = namepad,
...
@@ -130,6 +136,11 @@ fn printtask(cfg: config, t: task, id: size) (void | error) = {
width = pad,
...
},
+ stags, &fmt::mods {
+ pad = ' ',
+ width = tagspad,
+ ...
+ },
p, &fmt::mods {
pad = ' ',
width = pathpad,
@@ -155,8 +166,9 @@ fn do(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
fn filter(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
const headpad = PADDING - len("name") + len("priority");
const namepad = 10 - len("id") + len("name");
- const pathpad = 15 - len("priority") + len("path");
- fmt::printfln("id{%}{%}{%}",
+ const tagspad = 15 - len("priority") + len("tags");
+ const pathpad = 20 - len("priority") + len("path");
+ fmt::printfln("id{%}{%}{%}{%}",
"name", &fmt::mods {
pad = ' ',
width = namepad,
@@ -165,6 +177,10 @@ fn filter(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
pad = ' ',
width = headpad,
...
+ },"tags", &fmt::mods {
+ pad = ' ',
+ width = tagspad,
+ ...
},"path", &fmt::mods {
pad = ' ',
width = pathpad,
@@ -190,7 +206,7 @@ fn filter(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
};
fn tsv(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
- tsv::writerecord(os::stdout, ["id" ,"name", "priority", "path"])!;
+ tsv::writerecord(os::stdout, ["id" ,"name", "priority", "tags", "path"])!;
for (let i = 0z; i < len(tasks); i += 1) {
const t = tasks[i];
printtasktsv(cfg, t, i)?;
@@ -200,8 +216,9 @@ fn tsv(cfg: config, tasks: []task, a: arguments) (void | task | error) = {
fn listall(cfg: config, tasks: []task) void = {
const headpad = PADDING - len("name") + len("priority");
const namepad = 10 - len("id") + len("name");
- const pathpad = 15 - len("priority") + len("path");
- fmt::printfln("id{%}{%}{%}",
+ const tagspad = 15 - len("priority") + len("tags");
+ const pathpad = 20 - len("tags") + len("path");
+ fmt::printfln("id{%}{%}{%}{%}",
"name", &fmt::mods {
pad = ' ',
width = namepad,
@@ -210,6 +227,10 @@ fn listall(cfg: config, tasks: []task) void = {
pad = ' ',
width = headpad,
...
+ },"tags", &fmt::mods {
+ pad = ' ',
+ width = tagspad,
+ ...
},"path", &fmt::mods {
pad = ' ',
width = pathpad,