2021-07-10 11:44:06 +02:00
|
|
|
package format
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-08-20 11:27:12 +02:00
|
|
|
"sort"
|
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())
|
|
|
|
}
|
|
|
|
|
2021-08-20 10:01:35 +02:00
|
|
|
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-08-20 17:50:08 +02:00
|
|
|
sort.Sort(task.ByDefault(tasks))
|
2021-08-20 11:27:12 +02:00
|
|
|
|
2021-07-10 11:44:06 +02:00
|
|
|
var output string
|
|
|
|
for _, t := range tasks {
|
2021-08-21 20:47:29 +02:00
|
|
|
var updateStr string
|
|
|
|
if t.LocalUpdate.ForVersion != 0 {
|
|
|
|
updateStr = " *"
|
|
|
|
}
|
|
|
|
output += fmt.Sprintf("%d%s\t%s\t%s (%s)\n", t.LocalId, updateStr, t.Due.String(), t.Action, t.Project)
|
2021-07-10 11:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|
2021-07-27 07:10:01 +02:00
|
|
|
|
2021-08-20 10:01:35 +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
|
|
|
|
}
|