feat(archive): duration syntax and confirmation prompt

Problem: `:Pending archive` accepted only a bare integer for days and
silently deleted tasks with no confirmation, risking accidental data loss.

Solution: Accept duration strings (`7d`, `3w`, `2m`) via
`parse.parse_duration_to_days()`, show a `vim.ui.input` confirmation
prompt before removing tasks, and skip the prompt when zero tasks match.
This commit is contained in:
Barrett Ruth 2026-03-08 20:25:33 -04:00
parent 8cfdafe464
commit cfcaaca28b
4 changed files with 220 additions and 25 deletions

View file

@ -141,11 +141,24 @@ COMMANDS *pending-commands*
after the add.
*:Pending-archive*
:Pending archive [{days}]
:Pending archive [{duration}]
Permanently remove done and deleted tasks whose completion timestamp is
older than {days} days. {days} defaults to 30 if not provided. >vim
:Pending archive " remove tasks completed more than 30 days ago
:Pending archive 7 " remove tasks completed more than 7 days ago
older than {duration}. {duration} defaults to 30 days if not provided.
Supported duration formats:
`Nd` N days (e.g. `7d`)
`Nw` N weeks (e.g. `3w` → 21 days)
`Nm` N months (e.g. `2m` → 60 days, approximated as N×30)
`N` bare integer, treated as days (backwards-compatible)
A confirmation prompt is shown before any tasks are removed. If no
tasks match the cutoff, a message is displayed and no prompt appears.
>vim
:Pending archive " 30-day default, with confirmation
:Pending archive 7d " tasks completed more than 7 days ago
:Pending archive 3w " tasks completed more than 21 days ago
:Pending archive 2m " tasks completed more than 60 days ago
:Pending archive 30 " bare integer, same as 30d
<
*:Pending-due*