feat(sync): auto-discover backends, per-backend auth, S3 backend
Problem: sync backends were hardcoded in `SYNC_BACKENDS` list in `init.lua`, auth routed directly through `oauth.google_client`, and adding a non-OAuth backend required editing multiple files. Solution: replace hardcoded list with `discover_backends()` that globs `lua/pending/sync/*.lua` at runtime. Rewrite `M.auth()` to dispatch to per-backend `auth()` methods with `vim.ui.select` fallback. Add `lua/pending/sync/s3.lua` with push/pull/sync via AWS CLI, per-task merge by `_s3_sync_id` (UUID), and `pending.S3Config` type.
This commit is contained in:
parent
27190fd26c
commit
a83f500144
8 changed files with 1000 additions and 42 deletions
|
|
@ -183,7 +183,8 @@ end, {
|
|||
for word in after_filter:gmatch('%S+') do
|
||||
used[word] = true
|
||||
end
|
||||
local candidates = { 'clear', 'overdue', 'today', 'priority', 'done', 'pending', 'wip', 'blocked' }
|
||||
local candidates =
|
||||
{ 'clear', 'overdue', 'today', 'priority', 'done', 'pending', 'wip', 'blocked' }
|
||||
local store = require('pending.store')
|
||||
local s = store.new(store.resolve_path())
|
||||
s:load()
|
||||
|
|
@ -223,10 +224,22 @@ end, {
|
|||
end
|
||||
local trailing = after_auth:match('%s$')
|
||||
if #parts == 0 or (#parts == 1 and not trailing) then
|
||||
return filter_candidates(arg_lead, { 'gcal', 'gtasks', 'clear', 'reset' })
|
||||
local auth_names = {}
|
||||
for _, b in ipairs(pending.sync_backends()) do
|
||||
local ok, mod = pcall(require, 'pending.sync.' .. b)
|
||||
if ok and type(mod.auth) == 'function' then
|
||||
table.insert(auth_names, b)
|
||||
end
|
||||
end
|
||||
return filter_candidates(arg_lead, auth_names)
|
||||
end
|
||||
local backend_name = parts[1]
|
||||
if #parts == 1 or (#parts == 2 and not trailing) then
|
||||
return filter_candidates(arg_lead, { 'clear', 'reset' })
|
||||
local ok, mod = pcall(require, 'pending.sync.' .. backend_name)
|
||||
if ok and type(mod.auth_complete) == 'function' then
|
||||
return filter_candidates(arg_lead, mod.auth_complete())
|
||||
end
|
||||
return {}
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
|
@ -243,7 +256,13 @@ end, {
|
|||
end
|
||||
local actions = {}
|
||||
for k, v in pairs(mod) do
|
||||
if type(v) == 'function' and k:sub(1, 1) ~= '_' and k ~= 'health' then
|
||||
if
|
||||
type(v) == 'function'
|
||||
and k:sub(1, 1) ~= '_'
|
||||
and k ~= 'health'
|
||||
and k ~= 'auth'
|
||||
and k ~= 'auth_complete'
|
||||
then
|
||||
table.insert(actions, k)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue