taskwarrior-lua/src/taskwarrior.lua

24 lines
520 B
Lua
Raw Normal View History

2024-04-02 12:53:17 +00:00
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