2021-07-10 11:44:06 +02:00
|
|
|
package format
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-09-17 07:33:26 +02:00
|
|
|
"go-mod.ewintr.nl/gte/internal/task"
|
2021-07-10 11:44:06 +02:00
|
|
|
)
|
|
|
|
|
2022-06-05 13:00:23 +02:00
|
|
|
type Column int
|
2022-06-04 14:28:45 +02:00
|
|
|
|
|
|
|
const (
|
2022-06-05 13:00:23 +02:00
|
|
|
COL_ID Column = iota
|
2022-06-04 14:28:45 +02:00
|
|
|
COL_STATUS
|
2022-06-05 15:00:28 +02:00
|
|
|
COL_DUE
|
2022-06-05 13:00:23 +02:00
|
|
|
COL_ACTION
|
2022-06-04 14:28:45 +02:00
|
|
|
COL_PROJECT
|
|
|
|
)
|
|
|
|
|
2022-06-05 13:00:23 +02:00
|
|
|
var (
|
2022-06-05 15:00:28 +02:00
|
|
|
COL_ALL = []Column{COL_ID, COL_STATUS, COL_DUE, COL_ACTION, COL_PROJECT}
|
2022-06-05 13:00:23 +02:00
|
|
|
)
|
|
|
|
|
2021-07-10 11:44:06 +02:00
|
|
|
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 FormatTask(t *task.LocalTask) string {
|
2022-10-17 10:34:36 +02:00
|
|
|
tl := t
|
|
|
|
tl.ApplyUpdate()
|
|
|
|
|
2022-10-17 10:26:48 +02:00
|
|
|
output := fmt.Sprintf(`folder: %s
|
2022-10-17 10:34:36 +02:00
|
|
|
status: %s
|
2021-08-16 07:09:06 +02:00
|
|
|
action: %s
|
2021-07-27 07:10:01 +02:00
|
|
|
project: %s
|
2022-10-17 10:34:36 +02:00
|
|
|
`, tl.Folder, tl.LocalStatus, tl.Action, tl.Project)
|
2021-07-27 07:10:01 +02:00
|
|
|
if t.IsRecurrer() {
|
2022-10-17 10:34:36 +02:00
|
|
|
output += fmt.Sprintf("recur: %s\n", tl.Recur.String())
|
2022-10-17 10:28:59 +02:00
|
|
|
} else {
|
2022-10-17 10:34:36 +02:00
|
|
|
output += fmt.Sprintf("due: %s\n", tl.Due.String())
|
2021-07-27 07:10:01 +02:00
|
|
|
}
|
|
|
|
|
2022-10-17 10:26:48 +02:00
|
|
|
return fmt.Sprintf("\n%s\n", output)
|
2021-07-27 07:10:01 +02:00
|
|
|
}
|