diff --git a/cmd/cli/command/folder.go b/cmd/cli/command/folder.go index dbf8deb..9a5f988 100644 --- a/cmd/cli/command/folder.go +++ b/cmd/cli/command/folder.go @@ -1,6 +1,7 @@ package command import ( + "sort" "strings" "ewintr.nl/gte/cmd/cli/format" @@ -51,5 +52,7 @@ func (f *Folder) Do() string { return format.FormatError(err) } + sort.Sort(task.ByDefault(res.Tasks)) + return format.FormatTaskTable(res.Tasks, format.COL_ALL) } diff --git a/cmd/cli/command/project.go b/cmd/cli/command/project.go index 60a2ef8..31bc58e 100644 --- a/cmd/cli/command/project.go +++ b/cmd/cli/command/project.go @@ -1,12 +1,14 @@ package command import ( + "sort" "strings" "ewintr.nl/gte/cmd/cli/format" "ewintr.nl/gte/internal/configuration" "ewintr.nl/gte/internal/process" "ewintr.nl/gte/internal/storage" + "ewintr.nl/gte/internal/task" ) type Project struct { @@ -38,5 +40,8 @@ func (p *Project) Do() string { return format.FormatError(err) } - return format.FormatTaskTable(res.Tasks, format.COL_ALL) + sort.Sort(task.ByDefault(res.Tasks)) + cols := []format.Column{format.COL_ID, format.COL_STATUS, format.COL_DUE, format.COL_ACTION} + + return format.FormatTaskTable(res.Tasks, cols) } diff --git a/cmd/cli/command/projects.go b/cmd/cli/command/projects.go index 29017cd..5b9080e 100644 --- a/cmd/cli/command/projects.go +++ b/cmd/cli/command/projects.go @@ -38,12 +38,12 @@ func (p *Projects) Do() string { return "no projects here\n\n" } - var out string + var data [][]string for _, project := range projects { if project != "" { - out += fmt.Sprintf("%s\n", project) + data = append(data, []string{project}) } } - return fmt.Sprintf("%s\n", out) + return fmt.Sprintf("%s", format.FormatTable(data)) } diff --git a/cmd/cli/command/week.go b/cmd/cli/command/week.go index 52bcd44..fb84181 100644 --- a/cmd/cli/command/week.go +++ b/cmd/cli/command/week.go @@ -1,6 +1,8 @@ package command import ( + "sort" + "ewintr.nl/gte/cmd/cli/format" "ewintr.nl/gte/internal/configuration" "ewintr.nl/gte/internal/process" @@ -34,5 +36,7 @@ func (w *Week) Do() string { return format.FormatError(err) } + sort.Sort(task.ByDefault(res.Tasks)) + return format.FormatTaskTable(res.Tasks, format.COL_ALL) } diff --git a/cmd/cli/format/format.go b/cmd/cli/format/format.go index 1fe0f08..6dbc5ac 100644 --- a/cmd/cli/format/format.go +++ b/cmd/cli/format/format.go @@ -17,13 +17,13 @@ type Column int const ( COL_ID Column = iota COL_STATUS - COL_DATE + COL_DUE COL_ACTION COL_PROJECT ) var ( - COL_ALL = []Column{COL_ID, COL_STATUS, COL_DATE, COL_ACTION, COL_PROJECT} + COL_ALL = []Column{COL_ID, COL_STATUS, COL_DUE, COL_ACTION, COL_PROJECT} ) func FormatError(err error) string { @@ -44,14 +44,21 @@ func FormatTaskTable(tasks []*task.LocalTask, cols []Column) string { line = append(line, fmt.Sprintf("%d", t.LocalId)) case COL_STATUS: var updated []string + if t.IsRecurrer() { + updated = append(updated, "r") + } if t.LocalStatus == task.STATUS_UPDATED { updated = append(updated, "u") } if !t.Due.IsZero() && task.Today.After(t.Due) { updated = append(updated, "o") } - line = append(line, strings.Join(updated, "")) - case COL_DATE: + line = append(line, strings.Join(updated, " ")) + case COL_DUE: + if t.Due.IsZero() { + line = append(line, "") + continue + } line = append(line, t.Due.Human()) case COL_ACTION: line = append(line, t.Action) diff --git a/internal/task/date.go b/internal/task/date.go index d4d54d0..238e0f7 100644 --- a/internal/task/date.go +++ b/internal/task/date.go @@ -189,7 +189,6 @@ func (d Date) Human() string { return "-" } - fmt.Println(Today.String(), d.String()) if Today.Add(7).After(d) { return strings.ToLower(d.t.Format("Monday")) } diff --git a/internal/task/localtask.go b/internal/task/localtask.go index 5a26dad..ef1ce25 100644 --- a/internal/task/localtask.go +++ b/internal/task/localtask.go @@ -77,6 +77,9 @@ type ByDefault []*LocalTask func (lt ByDefault) Len() int { return len(lt) } func (lt ByDefault) Swap(i, j int) { lt[i], lt[j] = lt[j], lt[i] } func (lt ByDefault) Less(i, j int) bool { + if lt[i].IsRecurrer() != lt[j].IsRecurrer() { + return lt[i].IsRecurrer() + } if !lt[j].Due.Equal(lt[i].Due) { return lt[j].Due.After(lt[i].Due) }