diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-11 14:07:10 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-11 14:10:01 +0100 |
commit | da7dc88dd52671ddd3733cc8c5320ed6c5654c89 (patch) | |
tree | 95c7908c910b50deab5e43c6a1402b31f3cd1f78 /workstack.go | |
parent | ad898317914439c33e5670d9018646799f2d6c3f (diff) |
Added edit and descriptions
- Edit task with the "edit" command to change it's text
- Add descriptions to task with "desc" command, delete a description by
providing an empty description
- added `-d` flag to commands to act on done tasks
- fixed bug: Delete a tag that is used by a task
Diffstat (limited to 'workstack.go')
-rw-r--r-- | workstack.go | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/workstack.go b/workstack.go index 45b5d67..bfff166 100644 --- a/workstack.go +++ b/workstack.go @@ -8,6 +8,7 @@ package workstack import ( "fmt" "os" + "strings" "time" ) @@ -19,30 +20,47 @@ type TaskDone struct { type Tag string type Task struct { - Text string - Tag Tag + Text string + Description string + Tag Tag } +var ( + DateLayout string = "15:04:05 02/01/2006" +) + +const ( + TASK_LIST_COUNT = 5 + GOBDATA_FILENAME = "tasks.gob" +) + +// For formatting +const ( + RESET = "\033[0m" + CYAN = "\033[36m" + DESCRIPTION_PAD = " " +) + func (t TaskDone) String() string { return fmt.Sprintf("(%s) %s", t.Date.Format(DateLayout), t.Task) } func (t Task) String() string { + var s string + if t.Tag != "" { - return fmt.Sprintf("{%s} %s", t.Tag, t.Text) + s = fmt.Sprintf("{%s} %s", t.Tag, t.Text) } else { - return fmt.Sprintf("%s", t.Text) + s = fmt.Sprintf("%s", t.Text) } -} -var ( - DateLayout string = "15:04:05 02/01/2006" -) + if t.Description != "" { + s += "\n" + DESCRIPTION_PAD + + CYAN + strings.ReplaceAll(t.Description, "\n", "\n"+DESCRIPTION_PAD) + RESET + } -const ( - TASK_LIST_COUNT = 5 - GOBDATA_FILENAME = "workstack.gob" -) + return s +} func GetGobdataPath() string { p := os.Getenv("HOME") |