diff --git a/dist/plan b/dist/plan index 579d676..30ea2c6 100755 Binary files a/dist/plan and b/dist/plan differ diff --git a/plan/command/list.go b/plan/command/list.go index 7b3507e..7e3f910 100644 --- a/plan/command/list.go +++ b/plan/command/list.go @@ -3,6 +3,7 @@ package command import ( "fmt" "slices" + "sort" "time" "go-mod.ewintr.nl/planner/item" @@ -136,6 +137,25 @@ type ListResult struct { } func (lr ListResult) Render() string { + sort.Slice(lr.Tasks, func(i, j int) bool { + if lr.Tasks[i].Task.Project < lr.Tasks[j].Task.Project { + return true + } + if lr.Tasks[i].Task.Project > lr.Tasks[j].Task.Project { + return false + } + if lr.Tasks[i].Task.Recurrer == nil && lr.Tasks[j].Task.Recurrer != nil { + return true + } + if lr.Tasks[i].Task.Recurrer != nil && lr.Tasks[j].Task.Recurrer == nil { + return false + } + if lr.Tasks[i].Task.Date.After(lr.Tasks[j].Task.Date) { + return false + } + return lr.Tasks[i].LocalID < lr.Tasks[j].LocalID + }) + var showRec, showDur bool for _, tl := range lr.Tasks { if tl.Task.Recurrer != nil { diff --git a/plan/command/list_test.go b/plan/command/list_test.go index 23db38d..a19386e 100644 --- a/plan/command/list_test.go +++ b/plan/command/list_test.go @@ -24,12 +24,10 @@ func TestListParse(t *testing.T) { expErr bool }{ { - name: "empty", - main: []string{}, - fields: map[string]string{}, - expArgs: command.ListArgs{ - To: today, - }, + name: "empty", + main: []string{}, + fields: map[string]string{}, + expArgs: command.ListArgs{}, }, { name: "today",