feat: improve CLI output with relative dates, rich feedback, and recurring task info
Add relative date formatting (today, tomorrow, in 3d, etc.) for list and detail views. Add structured feedback helpers for add/complete/delete operations showing display IDs and parsed modifiers. Change Complete() to return spawned recurring instance so callers can display recurrence info. Add AppendTask to working set for immediate display ID assignment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -143,19 +143,23 @@ func FormatTaskDetail(task *Task) string {
|
||||
}
|
||||
|
||||
if task.Due != nil {
|
||||
t.AppendRow(table.Row{"Due", formatTimeWithColor(*task.Due)})
|
||||
dueStr := FormatDateWithRelative(*task.Due)
|
||||
if task.Due.Before(timeNow()) {
|
||||
dueStr = color.RedString(dueStr)
|
||||
}
|
||||
t.AppendRow(table.Row{"Due", dueStr})
|
||||
}
|
||||
|
||||
if task.Scheduled != nil {
|
||||
t.AppendRow(table.Row{"Scheduled", formatTime(*task.Scheduled)})
|
||||
t.AppendRow(table.Row{"Scheduled", FormatDateWithRelative(*task.Scheduled)})
|
||||
}
|
||||
|
||||
if task.Wait != nil {
|
||||
t.AppendRow(table.Row{"Wait", formatTime(*task.Wait)})
|
||||
t.AppendRow(table.Row{"Wait", FormatDateWithRelative(*task.Wait)})
|
||||
}
|
||||
|
||||
if task.Until != nil {
|
||||
t.AppendRow(table.Row{"Until", formatTime(*task.Until)})
|
||||
t.AppendRow(table.Row{"Until", FormatDateWithRelative(*task.Until)})
|
||||
}
|
||||
|
||||
if task.RecurrenceDuration != nil {
|
||||
@@ -310,16 +314,20 @@ func formatDue(due *time.Time) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
rel := FormatRelativeDate(*due)
|
||||
|
||||
now := timeNow()
|
||||
if due.Before(now) {
|
||||
return color.RedString(due.Format("2006-01-02"))
|
||||
return color.RedString(rel)
|
||||
}
|
||||
|
||||
if due.Before(now.Add(24 * time.Hour)) {
|
||||
return color.YellowString(due.Format("2006-01-02"))
|
||||
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
tomorrow := today.Add(24 * time.Hour)
|
||||
if due.Before(tomorrow) {
|
||||
return color.YellowString(rel)
|
||||
}
|
||||
|
||||
return due.Format("2006-01-02")
|
||||
return rel
|
||||
}
|
||||
|
||||
func formatTimeWithColor(t time.Time) string {
|
||||
|
||||
Reference in New Issue
Block a user