Compare commits
3 commits
91c7d26c48
...
5b7ce8e6f3
Author | SHA1 | Date | |
---|---|---|---|
5b7ce8e6f3 | |||
506713711e | |||
e023b40575 |
2 changed files with 16 additions and 4 deletions
9
readme.md
Normal file
9
readme.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# 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.
|
|
@ -8,8 +8,11 @@ local function shellescape(str)
|
|||
return "'"..str:gsub([[']], [['"'"']]).."'"
|
||||
end
|
||||
|
||||
|
||||
--- @alias Task table
|
||||
--- @class Task
|
||||
--- @field description string
|
||||
--- @field uuid string
|
||||
--- @field due string
|
||||
--- @field status "pending"|"completed"|"deleted"|"waiting"
|
||||
|
||||
--- Imports all tasks from Taskwarrior according to filters if given
|
||||
--- @param ... string Taskwarrior filters as individual strings
|
||||
|
@ -19,13 +22,13 @@ function taskwarrior.import(...)
|
|||
for i, filter in ipairs(filters) do
|
||||
filters[i] = shellescape(filter)
|
||||
end
|
||||
return json.decode(io.popen("task "..table.concat(filters, " ").." export"):read("*a"))
|
||||
return json.decode(io.popen("task rc.verbose: "..table.concat(filters, " ").." export"):read("*a"))
|
||||
end
|
||||
|
||||
--- Export tasks back into taskwarrior using the import command
|
||||
--- @param items Task[] Sequence of tasks to import
|
||||
function taskwarrior.export(items)
|
||||
local handle = assert(io.popen("task import"))
|
||||
local handle = assert(io.popen("task rc.verbose: import"))
|
||||
handle:write(json.encode(items))
|
||||
handle:close()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue