24 lines
520 B
Lua
24 lines
520 B
Lua
|
local json = require "cjson"
|
||
|
|
||
|
local taskwarrior = {}
|
||
|
|
||
|
local function shellescape(str)
|
||
|
return "'"..str:gsub([[']], [['"'"']]).."'"
|
||
|
end
|
||
|
|
||
|
function taskwarrior.import(...)
|
||
|
local filters = {...}
|
||
|
for i, filter in ipairs(filters) do
|
||
|
filters[i] = shellescape(filter)
|
||
|
end
|
||
|
return json.decode(io.popen("task "..table.concat(filters, " ").." export"):read("*a"))
|
||
|
end
|
||
|
|
||
|
function taskwarrior.export(items)
|
||
|
local handle = assert(io.popen("task import"))
|
||
|
handle:write(json.encode(items))
|
||
|
handle:close()
|
||
|
end
|
||
|
|
||
|
return taskwarrior
|