From da7dc88dd52671ddd3733cc8c5320ed6c5654c89 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 11 Nov 2024 14:07:10 +0100 Subject: 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 --- workstack.go | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'workstack.go') 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") -- cgit v1.2.3