WriteTodos renders a report of todos
(todos ToDos, writer io.Writer)
| 21 | |
| 22 | // WriteTodos renders a report of todos |
| 23 | func WriteTodos(todos ToDos, writer io.Writer) error { |
| 24 | |
| 25 | t, err := template.New("todos").Parse(defaultTemplate) |
| 26 | if err != nil { |
| 27 | return err |
| 28 | } |
| 29 | |
| 30 | // replace the phrase in the todo string with a "highlighted" version for console output |
| 31 | // TODO eventually make this configurable, for NO_COLOR output (or customization of color?) |
| 32 | for _, todo := range todos { |
| 33 | todo.String = strings.Replace(todo.String, todo.Phrase, "\u001b[33m"+todo.Phrase+"\u001b[0m", 1) |
| 34 | } |
| 35 | |
| 36 | err = t.Execute(writer, todos) |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | |
| 41 | return nil |
| 42 | } |