refactor: normalize log message grammar and capitalization

Problem: Log messages used inconsistent capitalization, punctuation,
and phrasing — some started lowercase, some omitted periods, "Pending"
was used instead of "task", and sync backend errors used ad-hoc
formatting.

Solution: Apply sentence case after backend prefixes, add trailing
periods to complete sentences, rename "Pending" to "task", use
`'Failed to <verb> <noun>: '` pattern for operation errors, and
pluralize "Archived N task(s)" correctly.
This commit is contained in:
Barrett Ruth 2026-03-06 18:37:02 -05:00
parent 874ff381f9
commit ca18574756
5 changed files with 28 additions and 28 deletions

View file

@ -87,7 +87,7 @@ end
local function require_saved()
local bufnr = buffer.bufnr()
if bufnr and vim.bo[bufnr].modified then
log.warn('save changes first (:w)')
log.warn('Save changes first (:w).')
return false
end
return true
@ -511,7 +511,7 @@ function M.done(id_str)
if bufnr and vim.api.nvim_buf_is_valid(bufnr) then
buffer.render(bufnr)
end
log.info('Task #' .. id .. ' marked ' .. (was_done and 'pending' or 'done'))
log.info('Task #' .. id .. ' marked ' .. (was_done and 'pending' or 'done') .. '.')
end
---@return nil
@ -601,7 +601,7 @@ function M.add(text)
s:load()
local description, metadata = parse.command_add(text)
if not description or description == '' then
log.error('Pending must have a description.')
log.error('Task must have a description.')
return
end
s:add({
@ -616,7 +616,7 @@ function M.add(text)
if bufnr and vim.api.nvim_buf_is_valid(bufnr) then
buffer.render(bufnr)
end
log.info('Pending added: ' .. description)
log.info('Task added: ' .. description)
end
---@type string[]
@ -649,7 +649,7 @@ local function run_sync(backend_name, action)
return
end
if action == 'health' or type(backend[action]) ~= 'function' then
log.error(backend_name .. " backend has no '" .. action .. "' action")
log.error(backend_name .. ": No '" .. action .. "' action.")
return
end
backend[action]()
@ -687,7 +687,7 @@ function M.archive(days)
end
s:replace_tasks(kept)
_save_and_notify()
log.info('Archived ' .. archived .. ' tasks.')
log.info('Archived ' .. archived .. ' task' .. (archived == 1 and '' or 's') .. '.')
local bufnr = buffer.bufnr()
if bufnr and vim.api.nvim_buf_is_valid(bufnr) then
buffer.render(bufnr)
@ -915,7 +915,7 @@ function M.edit(id_str, rest)
buffer.render(bufnr)
end
log.info('Task #' .. id .. ' updated: ' .. table.concat(feedback, ', '))
log.info('Task #' .. id .. ' updated: ' .. table.concat(feedback, ', ') .. '.')
end
---@param args? string
@ -977,7 +977,7 @@ function M.command(args)
elseif cmd == 'undo' then
M.undo_write()
else
log.error('Unknown Pending subcommand: ' .. cmd)
log.error('Unknown subcommand: ' .. cmd)
end
end