gte/cmd/cli/format/format.go

39 lines
767 B
Go
Raw Normal View History

2021-07-10 11:44:06 +02:00
package format
import (
"fmt"
2021-08-20 11:02:30 +02:00
"strings"
2021-07-10 11:44:06 +02:00
"git.ewintr.nl/gte/internal/task"
)
func FormatError(err error) string {
return fmt.Sprintf("could not perform command.\n\nerror: %s\n", err.Error())
}
func FormatTaskTable(tasks []*task.LocalTask) string {
2021-07-14 07:17:53 +02:00
if len(tasks) == 0 {
return "no tasks to display\n"
}
2021-07-10 11:44:06 +02:00
var output string
for _, t := range tasks {
2021-08-20 11:02:30 +02:00
output += fmt.Sprintf("%d\t%s\t%s (%s, %s)\n", t.LocalId, t.Due.String(), t.Action, t.Project, strings.ToLower(t.Folder))
2021-07-10 11:44:06 +02:00
}
return output
}
2021-07-27 07:10:01 +02:00
func FormatTask(t *task.LocalTask) string {
2021-08-16 07:09:06 +02:00
output := fmt.Sprintf(`folder: %s
action: %s
2021-07-27 07:10:01 +02:00
project: %s
due: %s
2021-08-16 07:09:06 +02:00
`, t.Folder, t.Action, t.Project, t.Due.String())
2021-07-27 07:10:01 +02:00
if t.IsRecurrer() {
output += fmt.Sprintf("recur:%s", t.Recur.String())
}
return output
}