Add doc annotations

This commit is contained in:
Talia 2024-04-02 15:03:27 +02:00
parent 02cab39e47
commit 91c7d26c48

View file

@ -2,10 +2,18 @@ local json = require "cjson"
local taskwarrior = {} local taskwarrior = {}
--- @param str string
--- @return string
local function shellescape(str) local function shellescape(str)
return "'"..str:gsub([[']], [['"'"']]).."'" return "'"..str:gsub([[']], [['"'"']]).."'"
end end
--- @alias Task table
--- Imports all tasks from Taskwarrior according to filters if given
--- @param ... string Taskwarrior filters as individual strings
--- @return Task[] tasks Sequence listing all tasks
function taskwarrior.import(...) function taskwarrior.import(...)
local filters = {...} local filters = {...}
for i, filter in ipairs(filters) do for i, filter in ipairs(filters) do
@ -14,6 +22,8 @@ function taskwarrior.import(...)
return json.decode(io.popen("task "..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
--- @param items Task[] Sequence of tasks to import
function taskwarrior.export(items) function taskwarrior.export(items)
local handle = assert(io.popen("task import")) local handle = assert(io.popen("task import"))
handle:write(json.encode(items)) handle:write(json.encode(items))