Compare commits

..

No commits in common. "5b7ce8e6f34a5c6fe680c30c65ec2f7102a61b27" and "91c7d26c48886e52d1ac37d99a452c20202a5f01" have entirely different histories.

2 changed files with 4 additions and 16 deletions

View file

@ -1,9 +0,0 @@
# Taskwarrior Lua
A simple lua helper to import and export task data to and from taskwarrior using
its builtin `import` and `export` commands.
The `import` function imports data into Lua using `task export` and vice versa.
The `import` function takes an optional list of filters to pass on to task
warrior to limit which tasks are to be updated.

View file

@ -8,11 +8,8 @@ local function shellescape(str)
return "'"..str:gsub([[']], [['"'"']]).."'" return "'"..str:gsub([[']], [['"'"']]).."'"
end end
--- @class Task
--- @field description string --- @alias Task table
--- @field uuid string
--- @field due string
--- @field status "pending"|"completed"|"deleted"|"waiting"
--- Imports all tasks from Taskwarrior according to filters if given --- Imports all tasks from Taskwarrior according to filters if given
--- @param ... string Taskwarrior filters as individual strings --- @param ... string Taskwarrior filters as individual strings
@ -22,13 +19,13 @@ function taskwarrior.import(...)
for i, filter in ipairs(filters) do for i, filter in ipairs(filters) do
filters[i] = shellescape(filter) filters[i] = shellescape(filter)
end end
return json.decode(io.popen("task rc.verbose: "..table.concat(filters, " ").." export"):read("*a")) return json.decode(io.popen("task "..table.concat(filters, " ").." export"):read("*a"))
end end
--- Export tasks back into taskwarrior using the import command --- Export tasks back into taskwarrior using the import command
--- @param items Task[] Sequence of tasks to import --- @param items Task[] Sequence of tasks to import
function taskwarrior.export(items) function taskwarrior.export(items)
local handle = assert(io.popen("task rc.verbose: import")) local handle = assert(io.popen("task import"))
handle:write(json.encode(items)) handle:write(json.encode(items))
handle:close() handle:close()
end end