feat: add \:Pending done <id>\ command (#76)

Toggles a task's done/pending status by ID from the command line,
matching the buffer \`<CR>\` behaviour including recurrence spawning.
Tab-completes active task IDs.
This commit is contained in:
Barrett Ruth 2026-03-05 23:56:11 -05:00
parent 829afd25b4
commit d4e4d1499a
3 changed files with 56 additions and 2 deletions

View file

@ -167,7 +167,7 @@ end, {
nargs = '*',
complete = function(arg_lead, cmd_line)
local pending = require('pending')
local subcmds = { 'add', 'archive', 'auth', 'due', 'edit', 'filter', 'undo' }
local subcmds = { 'add', 'archive', 'auth', 'done', 'due', 'edit', 'filter', 'undo' }
for _, b in ipairs(pending.sync_backends()) do
table.insert(subcmds, b)
end
@ -200,6 +200,16 @@ end, {
end
return filtered
end
if cmd_line:match('^Pending%s+done%s') then
local store = require('pending.store')
local s = store.new(store.resolve_path())
s:load()
local ids = {}
for _, task in ipairs(s:active_tasks()) do
table.insert(ids, tostring(task.id))
end
return filter_candidates(arg_lead, ids)
end
if cmd_line:match('^Pending%s+edit') then
return complete_edit(arg_lead, cmd_line)
end