gte/cmd/cli/format/format.go

39 lines
646 B
Go
Raw Normal View History

2021-07-10 11:44:06 +02:00
package format
import (
"fmt"
2021-09-19 11:59:26 +02:00
"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())
}
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())
}
2021-09-04 19:47:36 +02:00
return fmt.Sprintf("%s\n", output)
2021-07-27 07:10:01 +02:00
}