From 34639c4285621177efb10b82ddb07cd0017af56a Mon Sep 17 00:00:00 2001 From: Quey-Liang Kao Date: Sun, 20 Aug 2017 22:45:31 +0800 Subject: Redefine sub-commands: "ln" and "n" Sub-command "ln" is redefined to the function of listing all todos with their notes; "n" replaces original "ln", listing the notes of a specific todo. --- todolist/formatter.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'todolist/formatter.go') diff --git a/todolist/formatter.go b/todolist/formatter.go index 847be04..e7863db 100644 --- a/todolist/formatter.go +++ b/todolist/formatter.go @@ -25,7 +25,7 @@ func NewFormatter(todos *GroupedTodos) *Formatter { return formatter } -func (f *Formatter) Print() { +func (f *Formatter) Print(printNotes bool) { cyan := color.New(color.FgCyan).SprintFunc() var keys []string @@ -38,22 +38,17 @@ func (f *Formatter) Print() { fmt.Fprintf(f.Writer, "\n %s\n", cyan(key)) for _, todo := range f.GroupedTodos.Groups[key] { f.printTodo(todo) + if printNotes { + for nid, note := range todo.Notes { + fmt.Fprintf(f.Writer, " %s\t%s\t\n", + cyan(strconv.Itoa(nid)), note) + } + } } } f.Writer.Flush() } -func (f *Formatter) PrintNotes() { - cyan := color.New(color.FgCyan).SprintFunc() - todo := f.GroupedTodos.Groups[""][0] - f.printTodo(todo) - for nid, note := range todo.Notes { - fmt.Fprintf(f.Writer, " %s\t%s\t\n", - cyan(strconv.Itoa(nid)), note) - } - f.Writer.Flush() -} - func (f *Formatter) printTodo(todo *Todo) { yellow := color.New(color.FgYellow) if todo.IsPriority { -- cgit v1.3