From 91c7d26c48886e52d1ac37d99a452c20202a5f01 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 2 Apr 2024 15:03:27 +0200 Subject: [PATCH] Add doc annotations --- src/taskwarrior.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/taskwarrior.lua b/src/taskwarrior.lua index ce69d83..85ab6fe 100644 --- a/src/taskwarrior.lua +++ b/src/taskwarrior.lua @@ -2,10 +2,18 @@ local json = require "cjson" local taskwarrior = {} +--- @param str string +--- @return string local function shellescape(str) return "'"..str:gsub([[']], [['"'"']]).."'" 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(...) local filters = {...} 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")) 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")) handle:write(json.encode(items))