package workstack // Workstack or ws for short is a program that manages To-Do's in a stack-based fashion. It tries // to guide your focus to your three most important tasks such that you do not get distracted by // other tasks. // Task have a Do state where they are on the stack and a Done state when they are archived. import ( "fmt" "os" "strings" "time" ) type TaskDone struct { Task Task Date time.Time } type Tag string type Task struct { Text string Description string Tag Tag } var ( DateLayout string = "15:04:05 02/01/2006" ) const ( TASK_LIST_COUNT = 5 GOBDATA_FILENAME = "tasks.gob" TMPFILE = "tasks.ws" ) // 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 != "" { s = fmt.Sprintf("{%s} %s", t.Tag, t.Text) } else { s = fmt.Sprintf("%s", t.Text) } if t.Description != "" { s += "\n" + DESCRIPTION_PAD + CYAN + strings.ReplaceAll(t.Description, "\n", "\n"+DESCRIPTION_PAD) + RESET } return s } func GetGobdataPath() string { p := os.Getenv("HOME") if p == "" { panic("HOME var not set.") } return p + "/sync/share/" + GOBDATA_FILENAME }