list formatting
This commit is contained in:
parent
656988c052
commit
e910517fd3
|
@ -136,15 +136,46 @@ type ListResult struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr ListResult) Render() string {
|
func (lr ListResult) Render() string {
|
||||||
data := [][]string{{"id", "project", "date", "dur", "title"}}
|
var showRec, showDur bool
|
||||||
for _, tl := range lr.Tasks {
|
for _, tl := range lr.Tasks {
|
||||||
data = append(data, []string{
|
if tl.Task.Recurrer != nil {
|
||||||
fmt.Sprintf("%d", tl.LocalID),
|
showRec = true
|
||||||
tl.Task.Project,
|
}
|
||||||
tl.Task.Date.String(),
|
if tl.Task.Duration > time.Duration(0) {
|
||||||
tl.Task.Duration.String(),
|
showDur = true
|
||||||
tl.Task.Title,
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
title := []string{"id"}
|
||||||
|
if showRec {
|
||||||
|
title = append(title, "rec")
|
||||||
|
}
|
||||||
|
title = append(title, "project", "date")
|
||||||
|
if showDur {
|
||||||
|
title = append(title, "dur")
|
||||||
|
}
|
||||||
|
title = append(title, "title")
|
||||||
|
|
||||||
|
data := [][]string{title}
|
||||||
|
for _, tl := range lr.Tasks {
|
||||||
|
row := []string{fmt.Sprintf("%d", tl.LocalID)}
|
||||||
|
if showRec {
|
||||||
|
recStr := ""
|
||||||
|
if tl.Task.Recurrer != nil {
|
||||||
|
recStr = "*"
|
||||||
|
}
|
||||||
|
row = append(row, recStr)
|
||||||
|
}
|
||||||
|
row = append(row, tl.Task.Project, tl.Task.Date.String())
|
||||||
|
if showDur {
|
||||||
|
durStr := ""
|
||||||
|
if tl.Task.Duration > time.Duration(0) {
|
||||||
|
durStr = tl.Task.Duration.String()
|
||||||
|
}
|
||||||
|
row = append(row, durStr)
|
||||||
|
}
|
||||||
|
row = append(row, tl.Task.Title)
|
||||||
|
data = append(data, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("\n%s\n", format.Table(data))
|
return fmt.Sprintf("\n%s\n", format.Table(data))
|
||||||
|
|
Loading…
Reference in New Issue